2.c++ 字符串

include

include //c++ 使用时

using namespace std;

//1.c 风格字符串: char 变量名[] = "字符串值"
//2.c++ 风格字符串: string 变量名 = "字符串值"

int main()
{
//1.c风格
char str1[] = "hello world";
cout << str1 << endl;

//2.c++ 风格
string str2 = "hello world!!!!!";
cout << str2 << endl;


system("pause");

return 0;

}

posted @ 2025-06-23 11:57  little小新  阅读(4)  评论(0)    收藏  举报