Xcode/cout/complex Problem

Hi,
Apologies if this is the wrong place for this. I have tried a few fora with this query and so far no luck. The following really simple segment:

1
2
3
4
5
6
7
8
9
#include <iostream>
#include <complex>

int main (int argc, char * const argv[]) 
{
    std::complex<double> a(1.,1.);
    std::cout << "a = "<< a << "\n";
    return 0;
}


using Xcode 3.2 (the project setting is 'Command Line tool') on OSX 10.6.8 compiles fine and produces the following output:

a = (


when of course it should produce:

a = (1.,1.)


Yes, I can display the real and imaginary parts using a.real(), a.imag() but the above should work.

Any ideas why Xcode has this weird behaviour? Has anyone else seen this, any suggestions?
Cheers,
mk ii
No idea.

I've tested it three ways and they all work fine.

1) Visual Studio 2012 on Windows 7
2) XCode 4.5.2 on Mac OS X 10.8
3) Vim and g++ in Terminal on Mac OS X 10.8

All fine. :-S
Last edited on
Use std::endl instead of "\n".

Why do you think the output should be
a = (1.,1.) and not a = (1,1) or a = (1.0,1.0)?
Thanks kbw, IHutch105,
'... << std::endl;' makes no difference as does 'std::cout.flush();'.
Either of those three versions of output would be fine,
m
Topic archived. No new replies allowed.