ostringstream problem with int in c++

后端 未结 4 1783
我寻月下人不归
我寻月下人不归 2021-01-19 14:33

I would expect the following code to output hello5. Instead, it only outputs hello. It seems to be a problem with trying to output an int to the

相关标签:
4条回答
  • 2021-01-19 14:40

    I just tested and it worked just fine on my Mac with Xcode 3.2.1 and Snow Leopard. It not that your prompt is shadowing the output? Try add an endl to the cout line?

    -- Edit --

    My test suite

    • c++ test.cpp -- works fine
    • c++ -D_GLICXX_DEBUG=1 test.cpp -- fail
    • c++ -arch i386 -D_GLICXX_DEBUG=1 test.cpp -- works fine

    What can we say about this? In short, Debug version of 64 bit stdc++ seem to be broken.

    0 讨论(0)
  • 2021-01-19 14:45

    Yep, tested on this end (windows XP Pro) and it works swimmingly

    0 讨论(0)
  • 2021-01-19 14:47

    Changing the Active Configuration in XCode from 'Debug' to 'Release' works as a workaround.

    0 讨论(0)
  • 2021-01-19 14:52

    Your code is correct, it writes hello5 on my Windows 7 machine. Maybe the problem is rather that you don't write a std::endl or something which might confuse your OS.

    0 讨论(0)
提交回复
热议问题