my function here:
void listdisplay(int numrecords[55][7] , string stringrecords[55][2])
{
fstream file;
int length;
file.seekg(0 , ios::end);
length = file.tellg();
file.seekg(0 , ios::beg);
for (int i = 0; i < length; i += 1) {
cout<< setw(3) << numrecords[i][0] << setw(12) << stringrecords[i][0];
cout<< setw(12) << stringrecords[i][1] <<endl;
}
}
is what I had come up with after:
void listdisplay(int numrecords[55][7] , string stringrecords[55][2])
{
for (int i = 0; i < 55; i += 1) {
cout<< setw(3) << numrecords[i][0] << setw(12) << stringrecords[i][0];
cout<< setw(12) << stringrecords[i][1] <<endl;
}
}
The second thing will, for some reason, have random zeros after 50, as there was no data read after that, and suddenly loops again, and prints it one more time.
The top thing just doesn't even print out the array
Just as clarification,
numrecords[i][0] is the Pokemon number stringrecords[i][0] is the Pokemon name and stringrecords[i][1] is the Pokemon type
All in all, is there a way to find the end of an array, because reading the file till end of file is just a conditional loop with
!file.eof()!file.eof() as the condition.
Sorry for the long post

New Topic/Question
Reply



MultiQuote





|