鸟语天空
std::string
post by:追风剑情 2019-6-18 22:05

示例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;
}

运行测试

111.png

评论:
发表评论:
昵称

邮件地址 (选填)

个人主页 (选填)

内容