64,686
社区成员
发帖
与我相关
我的任务
分享
#include <sstream>
#include <iostream>
using namespace std;
int main()
{
ostringstream buf;
int i= 10;
float j=0.3;
buf<<"i="<<i<<endl;
buf.precision(10);
buf<<"j="<<j<<endl;
cout<<buf.str()<<endl;
}
#include <iostream>
#include <sstream>
using namespace std;
void main()
{
char buffer[256];
int i=3;
double d=5.5;
sprintf(buffer,"%i %f",i,d);
cout << buffer <<endl;
stringstream ss;
ss<<i<<" "<<d;
string s=ss.str();
cout << s << endl;
system("pause");
}
stringstream sstr;
sstr<<12<<" "<<34;
string str=sstr.str();
cout<<str<<endl;