#include <iostream>
bool toggle_sync()
{
bool init;
if (init = std::ios::sync_with_stdio())
std::ios::sync_with_stdio(false);
else std::ios::sync_with_stdio(true);
if (init != std::ios::sync_with_stdio())
returntrue;
elsereturnfalse;
}
int main()
{
for (int x = 0; x < 3; ++x)
{
std::cout << "First its " << std::ios::sync_with_stdio() << std::endl;
if (toggle_sync())
std::cout << "Positive.\n" << std::flush;
else std::cout << "Negative.\n" << std::flush;
std::cout << "Now its " << std::ios::sync_with_stdio() << std::endl;
}
return 0;
}
gives me:
First its 1
Positive.
Now its 0
First its 0
Negative.
Now its 0
First its 0
Negative.
Now its 0
Process returned 0 (0x0) execution time : 0.047 s
Press any key to continue.