更新时间:2023-02-03 09:56:35
我想应该是:如何编写一个用三个整数表示的字符串?"
您可以出于以下目的使用stringstream
对象:
It should be, I suppose: "How to write a string with the representation of three integers?"
You may use astringstream
object for the purpose:
#include <string>
#include <sstream>
using namespace std;
int main()
{
string str;
stringstream s;
int i,j,k;
i = 5; j=-7; k = 1000;
s << i << " " << j << " " << k << endl;
str = s.str();
}
char str[30];
sprintf(str, "%d %d %d", a, b, c);