Hi I have question regarding cin and buffer.
I want to make a simple io program which takes integers.
Anyway I stumbled to a problem with buffer. Using MinGW in windows7 the following code will print out all four integers that I input. But when I switch to SunOS and compile it with G++ it will only print out the first integer. Is this a compiler issue or is it a operating system issue?
#include <iostream>
using namespace std;
int main()
{
int i;
cout << "Enter four integers: ";
cin >> i;
cout << "\nYou entered the numbers: " << i << " ";
cin >> i; cout << " ";
cin >> i; cout << " ";
cin >> i; cout << " ";
return 0;
}
The code should print out the first number on pretty any system.
versus
Therefore many guidelines state to do only one operation per line. The cin just optically clutters the reading. Actually you never output
iexcepted the first time.