-
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.
-
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
-
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/