If you can provide some code snippet then i will be very thankful.
If you want to read a text file par line.
#include <fstream>
#include <iostream>
using namespace std;
int main() {
ifstream ifs("data.txt");
string buf;
while(ifs && getline(ifs, buf)) {
cout << buf << endl;
}
return 0;
}
// language: c++
This can be written also as following.
ifs >> buf;
cout << buf << endl;
// language: c++
Or if you want to read whole of one.
ifstream ifs("data.txt");
string str((istreambuf_iterator<char>(ifs)), istreambuf_iterator<char>());
// language: c++
精彩评论