Hey, I am trying to read in a random number of ints from a file into an array of pointers, while also incrementing the size of the array to match the number of new ints...
I have come up with this piece of code which somehow works, but doesnt store the values in memory, when i try to print them out somewhere else i just get a lot of 0's
int* scores;
int counter = 0;
while(!ins.eof())
{
scores = new int[counter+1];
ins >> scores[counter];
cout << scores[counter] << endl;
counter++;
}
for( int i = 0; i < counter; i++)
{
cout << scores[i] << endl;
}
it will print out the correct number in the while loop, but prints out 0's in the for loop, please help me
the txt file its reading from just has a few ints each on a new line like
23
12
5
21...