I have a simple text file having the following content
word1 word2
I need to read it on the first line in my C ++ application. After running the code ...
std::string result;
std::ifstream f( "file.txt" );
f >> result;
... but the result variable will be equal to "word1". It should be equal to "word1 word2" (the first line of the text file) Yes, I know that I can use the readline (f, result) function, but is there a way to do the same using the → style. It can be much prettier. Perhaps some manipulators that I don't know about will be useful here?
source
share