|
-
July 21st, 1999, 12:39 PM
#1
c++ text files
I am currently trying to access a text file throught visual c++ 5.0, I can
access the first line of the text file using CStdioFile::ReadString class
but I can not access any other line. The txt file is basicaly just a list of
names , a different name on each line, "line sizes is varied 10-100 chars so
I must access line by line ". readstring seems to be ment to access line by
line but there is no way to move to other lines.
-
July 21st, 1999, 01:37 PM
#2
Re: c++ text files
Here is a quick and dirty example of how i would do it:
ifstream fileToRead(fileName);
char oneLine[100];
if(!fileToRead)
//exit - do whatever
while(fileToRead.getline( oneLine, sizeof(oneLine)))
{
parseLine(oneLine);
}
if(! fileToRead.eof())
//exit/error - do whatever
-
July 21st, 1999, 01:46 PM
#3
Re: c++ text files
Check out my Example 16 at http://home.earthlink.net/~railro/mfc_link.html... I would consider using a CStringList object to hold the strings and which would allow you to traverse the list.
Rail
Recording Engineer/Software Developer
Rail Jon Rogut Software
[email protected]
http://home.earthlink.net/~railro/
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
|