1. 程式人生 > 其它 >C++:字串總結

C++:字串總結

技術標籤:C++字串c語言

#include <iostream>
#include <string>  //使用字串時需要新增的標頭檔案
using namespace std;
int main()
{
	/*
	用於表示一串字元
	C語言風格:char 變數名[]="字串值"
	C++風格:string 變數名="字串值"
	*/
	string str = "hello world";
	cout << str << endl;
	system("pause"
); return 0; }

執行:
在這裡插入圖片描述