Hello everyone I was hoping someone could point me in the right direction with a problem I have reading from a text file.
I am trying to find out how many lines of data are in a text file,the file will contain a list of names in this sort of format:
john
dave
bob
etc.
I have written the following code so far:
The program runs and gets stuck in the while loop, Is this due to the fact nothing is being done with the data in the file whilst in the loop?
I dont want to read the data (names) in from file untill I know how many lines are in there.
Anybody got any tips?
cheers
Stu.
I am trying to find out how many lines of data are in a text file,the file will contain a list of names in this sort of format:
john
dave
bob
etc.
I have written the following code so far:
Code:
filesize=0; fstream file1; file1.open("graph.txt",ios::in); { while(!file1.eof()) { filesize++; } } file1.close();
I dont want to read the data (names) in from file untill I know how many lines are in there.
Anybody got any tips?
cheers
Stu.
Comment