I have created an input stream to read from a text file. I am able to read the first line using Infile.get(array,characters,'\n');
How do i read the second line? How do i get the program to read the next line form the text file.
I have created an input stream to read from a text file. I am able to read the first line using Infile.get(array,characters,'\n');
How do i read the second line? How do i get the program to read the next line form the text file.
Call infile.get in a loop perhaps?
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Call infile.getline() in a loop that checks for the .eof() flag to be set.
What is EOF? and Why using feof() in a loop is bad, and ways to fix it.
getfile keeps reading the same line. I tried it in a loop and it still reads only the first line. Could u plz give me a small example.
Code:std::ifstream file("yatta.txt"); std::string line; while(still_reading_lines) { std::getline(file, line); }
MagosX.com
Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime.