I've run into kind of a wall as far as reading from files goes. I need a way to read the file line by line. Is there any standard function that I can use to read the file one line at a time?
I've run into kind of a wall as far as reading from files goes. I need a way to read the file line by line. Is there any standard function that I can use to read the file one line at a time?
Yep!
istream::getline will to the trick.
Apply it to an ifstream just like you would to cin, a la:
Code:char buf[255]; ifstream infile; infile.open("/home/user/file", ios::in); infile.getline(buf, 255); cout << buf << '\n';