0
Why is my code not asking for an input???
3 Antworten
+ 3
1. Limitation of Code Playground code processor. To overcome this, you can do
int dummy {};
std::cin >> dummy;
Before main() returns, to provoke the input dialog.
2. You need to call .ignore() and .clear() on std::cin before you can read <strBuf> in again the second time. Otherwise, only first read will succeed.
+ 2
Rishi,
I am not sure whether input stream and output stream flushes in-sync. As I understand, `std::endl` flushes the output stream, but I'm not sure whether it also flushes the input stream.
I only know this one ...
http://www.cplusplus.com/reference/ostream/ostream/flush/
+ 1
Ipang ooh, tnx. But I have another doubt too. I ran this in Cxxdroid, I gave input
"Hello!
Hello!"
But it didn't take the second "Hello!". I know it's because of the newline being in the input buffer, but std::endl should flush it right?
Also, are there any other ways to flush output buffer?