I have a simple text file, that has following content
word1 word2
I need to read it’s first line in my C++ application.
Following code works, …
std::string result;
std::ifstream f( "file.txt" );
f >> result;
… but result variable will be equal to “word1”. It should be equal to “word1 word2” (first line of text file)
Yes, i know, that i can use readline(f, result) function, but is there a way to do the same, using >> style. This could be much more pretty.
Possible, some manipulators, i don’t know about, will be useful here ?
No, there isn’t. Use
getline(f, result)to read a line.