By default, the standard input device is tied together with the standard output device in the form:
std::cin.tie (&std::cout);
which guarantees that the output buffer has been flushed before input is invoked. So I try to untie them by using std::cin.tie(0)
, but it seems that the result, has no difference with the tied one.
#include<iostream>
using namespace std;
int main(int argc, char *argv[])
{
char c;
cin.tie(0)
cout << "Please enter c:";
cin >> c;
cout << c ;
return 0;
}
Am I testing wrong? Why do we need to tie them together? Do they share the same buffer?
See Question&Answers more detail:os