Hi I liked of allocate dinamicing an array in real time, but be giving error! This is my code:
#include <iostream>
using namespace std;
int main()
{
int x, i = 0;
int *a = nullptr;
cout <<"";
while(cin >> x && cin.peek() != '\n'){
a = new int[i];
cout << x << " ";
a[i] = x;
i++;
}
cout<< x <<" \nEND\n" <<endl;
for(int j = 0; j < i; j++){
cout<< a[j] << " ";
}
delete[] a;
a = nullptr;
return 0;
}
Last edited on
Sorry..... I repaired the code