0
Working on Files
I've learnt working on files with c++ and now I know how to modify a text file .txt and write something in it..but can I make a code that read a text file and prints the words in the text file on console application?? I'm a beginner :)
2 Answers
+ 2
Yes you can.
But if you've learnt with SoloLearn c++ curses, you may not see it is located at the end of the file section ( second part ) who's cover writing :P :
#include <iostream>
#include <fstream>
using namespace std;
int main() {
string line;
ifstream MyFile("test.txt");
while (getline(MyFile,line)) {
cout << line << '\n';
}
}
0
Oh I didn't notice that..THANKS!