示例1:to_string()
#include <iostream>
#include <string>
using namespace std;
int main()
{
const int SIZE = 4;
string arr[SIZE];
int i;
for (i = 0; i < SIZE; i++)
{
arr[i] = "s" + to_string(i);
}
for (i = 0; i < SIZE; i++)
{
cout << (arr[i]) << " ";
}
cout << "\nPress any key to continue...";
char pl[20];
cin.getline(pl, 20);
return 0;
}
运行测试