私はコードを書いています
#include<sstream>
#include<iostream>
using namespace std;
int main(){
strstream temp;
int t =10;
temp>>10;
string tt ="testing"+temp.str();
問題があります。一時変数に対してはまったく機能しません。結果として、文字列テストのみで結果が得られ、最後に 10 はありませんか?
}
私はコードを書いています
#include<sstream>
#include<iostream>
using namespace std;
int main(){
strstream temp;
int t =10;
temp>>10;
string tt ="testing"+temp.str();
問題があります。一時変数に対してはまったく機能しません。結果として、文字列テストのみで結果が得られ、最後に 10 はありませんか?
}
The problem looks (to me) like a simple typo. You need to replace: temp>>10; with temp<<10;.
You should use operator<<() instead, temp << 10;.
As you have included sstream, I think you had the ostringstream class in mind.
ostringstream temp;
int i = 10;
temp << i;
string tt = "testing" + temp.str();
To use strstream, include <strstream>. strstream work with char*, which are C strings. Use ostringstream to work with objects of type basic_string.