学习字符串变量
1:字符串代码演示
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
//C语言风格的字符串变量:
char String_1[] = "Hello World";
cout << String_1 << endl;
//C++语言风格的字符串变量:
string String_2 = "Hello World";
cout << String_2 << endl;
system("pause");
return 0;
}
2:运行效果图
3:总结
C语言中,字符串变量用char 标识符[]
C++语言中,直接利用string 类变量