I was trying to write to a file or save the string s.substr (space_pos)
in a vector as fast as possible. I tried to write it to a file with ofstream
or to output it with cout
but it takes a long time. The size of the text file is 130mb.
This is the code:
fstream f(legitfiles.c_str(), fstream::in );
string s;
while(getline(f, s)){
size_t space_pos = s.rfind(" ") + 1;
cout << s.substr(space_pos) << endl;
ofstream results("results.c_str()");
results << s.substr(space_pos) << endl;
results.close();
}
cout << s << endl;
f.close();
Is there a way to write or print the string in a faster way?
Aucun commentaire:
Enregistrer un commentaire