数据类型-字符串类型

  • 字符串类型

 

点击查看代码
int main()
{
	//1、C风格字符串
	//注意事项
	// char 字符串名 [ ]
	// 等号后面要用 双引号包含起来字符串
	char str[] = "hello";	
	cout << str << endl;

	cout << sizeof(str) << endl; //6


	//2、C++风格字符串
	//注意包含头文件<string>
	string str2 = "world";
	cout << str2 << endl;

	cout << sizeof(str2) << endl; //32

	system("pause");

	return 0;
}

 

posted @ 2021-07-22 18:42  毋纵年华  阅读(51)  评论(0)    收藏  举报