int
에 string
에 stringstream
을 어떻게 할당합니까?stringstream에 int에 문자열을 어떻게 할당합니까?
은 "stringstream(mystr2) << b;
"아래의 예 mystr2
-b
를 할당하지 않습니다
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
int main()
{
string mystr = "1204";
int a;
stringstream(mystr) >> a;
cout << a << endl; // prints 1204
int b = 10;
string mystr2;
stringstream(mystr2) << b;
cout << mystr2 << endl; // prints nothing
return 0;
}
흠, 그는 아니, 첫 번째 부분과의 문제가 아니라했다? :) 'b'는 mystr2와 함께 거기에서 더 명확 해졌을 것입니다. – lpapp