Reputation: 357
I am implemting a program using c++, and i have a problem of geting the next line from an input file. I used:
const MAX 300;
char oneline[MAX];
ifstream in;
in.open("input.txt);
in.getline(oneline,MAX);
The function getline
always gets me the first line in the file. The thing is, how can I get the next line in the file?
Upvotes: 1
Views: 20998
Reputation: 7982
std::string line;
while(in.good())
{
getline(in, line);
//do something with line
}
Since you're using C++ you should use std::string to read your lines.
Upvotes: 3