Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ostringstream problem with int in c++

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 ostringstream. When I output the same directly to cout I receive the expected input. Using XCode 3.2 on Snow Leopard.

Thanks!

#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;
}

EDIT: See the answer I posted below. This seems to be created by a problem in the Active Configuration 'Debug' in XCode 3.2 on Snow Leopard

like image 770
Yuval Karmi Avatar asked Dec 30 '22 09:12

Yuval Karmi


1 Answers

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

like image 124
Yuval Karmi Avatar answered Jan 12 '23 05:01

Yuval Karmi