How do you read the file line by line?Code:#include <iostream> #include <fstream.h> #include <conio.h> #include <string> #define file "C:/Folder/File.txt" int main() { string word=""; ofstream a(file); a << "This is the first line." << endl; a << "This is the second line." << endl; a << "This is the third line." << endl; a << "This is the fourth line." << endl; a.close(); ifstream x(file); while (x >> word) { if (!x.eof()) { cerr << word << " "; x.seekg(NULL, ios::beg); x.clear(); } else { x.close(); } } x.close(); cin.get(); return 0; }
How do you go to a specific line in the text file and read it?(like go to line 4 and read the text there)
Is there anything I could put besides NULL in the first parameter of seekg?