Hello, so im trying to read an unknown number of numbers into an array, then do some math to those numbers. Im stuck on reading the data into an array...I cant quite figure out how to input the data into an array. can someone point me in the right direction? I've only included the part of the program that i'm having trouble with, if you need, i can post the entire thing
void functions::ReadData(int argc, char *argv[])
{
int counter =0;
char placeholder;
std::ifstream InStream(argv[1]);
while(!InStream.eof())
{
InStream >> placeholder;
counter++;
if (placeholder == '\n'|| placeholder == ' ')
counter --;
InStream.close();
}
//i open the file once todetermine size, then again to read data into array
int array [counter] = 0;
int * ptr = array;
InStream.open(argv[1]);
while (!InStream.eof())
{
InStream >> array;
ptr++;
//pointer arithmetic to chage address of array
}
InStream.close();
for(int i = 0; i < counter; i++)
{
std::cout << array[i] << std::endl;
}
}