when will the expression (std::cin>>buff) evaluate to false(0)?
I have been trying to take input until empty string is entered(simply press enter) ?
Is there any other way to achieve this?
profyou
13
Newbie Poster
Recommended Answers
Jump to PostHave a look at the stream
operator>>
here andoperator!
here. The extraction operator returns a reference to the stream, not a boolean value. You can check the stream state through its provided interface.
Jump to PostI have been trying to take input until empty string is entered(simply press enter) ?
The >> operator doesn't recognize whitespace except as a delimiter on both sides. If you just press enter, it's ignored while the >> operator waits for non-whitespace. To check for a blank line you would …
All 6 Replies
L7Sqr
227
Practically a Master Poster
deceptikon
1,790
Code Sniper
Team Colleague
Featured Poster
profyou
13
Newbie Poster
deceptikon
1,790
Code Sniper
Team Colleague
Featured Poster
profyou
13
Newbie Poster
deceptikon
1,790
Code Sniper
Team Colleague
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.