c中的int的ostringstream问题

前端之家收集整理的这篇文章主要介绍了c中的int的ostringstream问题前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_403_6@ 我希望以下代码输出hello5.相反,它只输出你好.
尝试将int输出到ostringstream似乎是一个问题.
当我直接输出相同的cout我收到预期的输入.在Snow Leopard上使用XCode 3.2.

谢谢!

#include <iostream>
#include <string>
#include <sstream>

using namespace std;

int main(){
 int myint = 5;
 string mystr = "hello";
 string finalstr;
 ostringstream oss;

 oss << mystr << myint;
 finalstr = oss.str();

 cout << finalstr;


 return 0;
}

编辑:看到我在下面发布的答案.这似乎是由Snow Leopard上的XCode 3.2中的Active Configuration’Defug’中的问题造成的

解决方法

将XCode中的活动配置从“调试”更改为“发布”可以解决此问题.

猜你在找的Xcode相关文章