online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
/* Escriba un programa en C++ a fin de crear un vector dinámico el cual debe llenarse ingresando enteros mayores a 0. Cada vez que se llene se debe re-dimensionar su tamaño , y continuar ingresando datos hasta que el usuario crea conveniente, el vector inicial tiene tamaño 1. Finalmente imprimir todos los valores del tamaño del vector actual con el formato indicado líneas abajo. Ejemplo: Ingrese enteros, termina con -1: 8 Ingrese enteros, termina con -1: 5 Ingrese enteros, termina con -1: 6 Ingrese enteros, termina con -1: 9 Ingrese enteros, termina con -1: 6 Ingrese enteros, termina con -1: -1 val 0: 8 val 1: 5 val 2: 6 val 3: 9 val 4: 6 */ #include <iostream> using namespace std; void redimensionar(int n, int *arrPtr); int main(){ int n=1, ent; int *arrPtr = new int[n]; while(1){ cout<<"Ingrese enteros, temina con -1: "; cin>>ent; if(ent == -1) break; arrPtr[n-1] = ent; n++; // redimensionar(n*2, arrPtr); redimensionar(n, arrPtr); } for(int i=0; i<n-1; i++){ cout<<"val "<<i<<": "<<arrPtr[i]<<endl; } delete[] arrPtr; arrPtr = NULL; return 0; } void redimensionar(int n, int *arrPtr){ int *aux=new int[n]; for(int i=0; i<n; i++){ aux[i]=arrPtr[i]; } arrPtr=aux; delete[] aux; aux=NULL; }

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