0
点赞
收藏
分享

微信扫一扫

2.6 字符串型

RockYoungTalk 2022-01-15 阅读 80

c风格字符串 char 变量[]=“字符串值”

string 变量名= “字符串值”;

#include<iostream>
#include<string>  // 字符串头文件
using namespace std;
int main()
{
    // c style 字符串 必须[]
    // = 后面要用双引号
    char str[] = "hello world";
    cout << str << endl;
    //c++ style 字符串 include 头文件
    string str2 = "hello world";
    cout << str2 << endl;
    system("pause");
    return 0;
}

举报

相关推荐

0 条评论