16th Aug 2021, 2:09 PM
Rishi
Rishi - avatar
3 ответов
+ 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.
16th Aug 2021, 2:18 PM
Ipang
+ 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/
16th Aug 2021, 2:40 PM
Ipang
+ 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?
16th Aug 2021, 2:25 PM
Rishi
Rishi - avatar