I've been working on this project for almost four hours now and I'm freaking out. It should be simple but I just can't figure it out. I need to read integers from a file and store it into an array. Some please help me!
TonyLFL
I've been working on this project for almost four hours now and I'm freaking out. It should be simple but I just can't figure it out. I need to read integers from a file and store it into an array. Some please help me!
TonyLFL
Do you know how many integers you are reading ahead of time?
25 integers, both negative and positive.
This is what I have so far:
const int arraySize = 25;
int a[ arraySize ], number, i;
ifstream ins( "numbers.dat" );
while ( ins >> number )
{
for ( i = 0; i < arraySize; i++)
ins >> a[ i ];
}
I'm storing all but the first integer in the data file into the array.
while ( ins >> number )
{
for ( i = 0; i < arraySize; i++)
ins >> a[ i ];
}
replace with..
for (int i = 0; i < arraySize; i++) {
ins >> a[i];
}
and that should do it...
Thank you, you have saved my sanity.
TonyLFL