[Dev-C++] Problem with 'std::cout' (?)
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Franco B. <fbr...@gm...> - 2007-10-04 14:15:17
|
Dear Friends,
I observed an irregular (I think) comportment of 'std::cout'
reproduced by the simple test code below:
#include <iostream>
using namespace std;
int myFunc(); // simple test function prototype
// test program
int main()
{
cout << myFunc() << endl // this block results
<< myFunc() << endl // in an inverted
<< myFunc() << endl << endl; // console output
cout << myFunc() << endl; // this block results
cout << myFunc() << endl; // in a correct
cout << myFunc() << endl << endl; // console output
system("PAUSE");
return 0;
}
// simple test function implementation
int myFunc()
{
static int i = 1024;
i /= 2;
return i;
}
The console output for this code is:
128
256
512
64
32
16
Press any key to continue...
The questions:
The two 'cout' blocks act in a different manner! (?)
Why the first chained block results in an inverted output?
Does not the insert operator '<<' act from left to right?
Obs.: I'm using
Dev-C++ 4.9.9.2,
Win XP 5.1,
g++ (1/29/2005).
TIA,
Franco Brancaccio
fbr...@gm...
|