Advertisement

getline() -- finding the end of the line

Started by September 12, 2000 01:36 AM
0 comments, last by GeniX 24 years, 3 months ago
Hey all, Using getline, I am wanting to read in (obviously) a line from a text file. Problem is there is a cut-off point past which on each line I may not want to read. So I read into a large buffer of 1k and find that say half way, and further I want to ignore the data. But what if the line is more than 1k long? Can I tell if getline still has more of the same line left to read? Because if I can then i can just repeatedly read the buffer in until i get to the new line. Any comments? regards, GeniX
regards,GeniXwww.cryo-genix.net
There is actually a version of getline that reads data into a std::string, so you don''t need to stress about buffer overruns:

std::string mystring;
std::ifstream ifile( "myfile.txt" );
std::getline( ifile, mystring );

This topic is closed to new replies.

Advertisement