vector
April 26th, 1999, 08:31 AM
I use CStdioFile::Open(...) to open a text file.
I want to get the lines of this text file and I want to Read any line directly.How can I do that?
Must I find all the "\r\n" in whole file?
Thanks in advance.:)
vector
Lothar Haensler
April 26th, 1999, 08:48 AM
call the ReadString member function until it returns FALSE (which means EOF) and increment your line counter after every read operation:
int i = 0;
while( myFile.ReadString(myCString)) {
i++;
...;
}
//i contains number of lines read.
Gomez Addams
April 26th, 1999, 12:37 PM
In addition to what Lothar said, you could build an array of seek locations of
every line by using GetPosition to tell you its starting point. With this you
could position the file pointer (using Seek) at the start of any line you want
and read it. But, you must first read every line once to be able to do this.