online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
/****************************************************************************** Online C++ Compiler. Code, Compile, Run and Debug C++ program online. Write your code in this editor and press "Run" button to compile and execute it. *******************************************************************************/ #include <iostream> using namespace std; typedef struct { int *data_ptr; }data_t; void restador (data_t *data){ while (*data->data_ptr>0){ // <== SI NO USAS EL ASTERISCO ESTAS HACIENDO REFERENCIA A LA POSICION DE MEMORIA, NO AL CONTENIDO QUE ESTA EN ESA POSICIÓN DE MEMORIA cout << "Resta " << *data->data_ptr; // <== Debes usar asterisco para hacer referencia al contenido del puntero. *data->data_ptr = (*data ->data_ptr-1); // más de lo mismo. } } int main() // <== NO ES VOID { int random_num; data_t *programa; srand(time (NULL)); random_num=(rand()%100)+1; programa->data_ptr=&random_num; // <== ESPERA RECIBIR UN TIPO DE DATO INT* (ES DECIR PUNTERO), no un tipo INT. restador (programa); // <== NO HACE FALTA PASARLE EL & PORQUE PROGRAMA YA INDICA LA DIRECCIÓN DE MEMORIA }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue