I'm currently learning some C++ while bored at work, sshing into my box at home. Doing some simple stuff doesn't work as I'd expect it to, though, namely with cout and cin.
Consider the following code:
<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>
#include <iostream>
<font color = green>int</font> main ()
{
<font color = green>int</font> i;
cout << <font color = red>"Please enter an integer value: "</font>;
cin >> i;
cout << <font color = red>"The value you entered is "</font> << i;
cout << <font color = red>" and its <font color = green>double</font> is "</font> << i*<font color = blue>2</font> << <font color = red>".\n"</font>;
<font color = green>return</font> <font color = blue>0</font>;
}
</font>[/code]
When I compile and run this (using /usr/bin/c++) it's like I have the cin before the cout or something:
parsec@localhost ~/learn % a.out
123
Please enter an integer value: The value you entered is 123 and its double is 246.
The exact same code works correctly on my school's solaris box:
@bacon[105]% ./a.out
Please enter an integer value: 123
The value you entered is 123 and its double is 246.
Now, I really don't know any c++ but I know C and Java. I've tried putting flush(cout) and cout.flush() before the cin, to no avail.
Can anyone help me out with how I can get my console i/o working the way it does on my school's machines?
Thanks,
parsec