I'm new to C++ and I'm teaching myself with the tutorial examples on the website. However I was wondering how do you read a full line from a text file? When it is input into a string it only reads until the first space.
Best regards
Ploe.
This is a discussion on How do I read a line from a file? within the C++ Programming forums, part of the General Programming Boards category; I'm new to C++ and I'm teaching myself with the tutorial examples on the website. However I was wondering how ...
I'm new to C++ and I'm teaching myself with the tutorial examples on the website. However I was wondering how do you read a full line from a text file? When it is input into a string it only reads until the first space.
Best regards
Ploe.
Did you look at the FAQ, or search?Code:ifstream in ("whatever.txt"); // leaving out error checking string MyString; getline( in, MyString ); cout<< MyString;
No sorry, like I said I'm new. But thank you very much that's exactly the information I wanted. From now on I'll look at the FAQ or search first.
Thanks again though!
>> [...] the FAQ or search first.
You, of course mean, FAQ and search, right![]()