|
-
April 26th, 1999, 08:31 AM
#1
How can I get the line number of a text file?
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
-
April 26th, 1999, 08:48 AM
#2
Re: How can I get the line number of a text file?
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.
-
April 26th, 1999, 12:37 PM
#3
Re: How can I get the line number of a text file?
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|