- 定义字符数组 存放字符串
#include<iostream>
using namespace std;
int main()
{
char str[]="I love CHINA";
cout<<str<<endl;
return 0;
}
- 用字符串变量存放字符串
#include<iostream>
#include<string>
using namespace std;
int main()
{
string str="I love CHINA";
cout<<str<<endl;
return 0;
}
- 用字符指针指向一个字符串
#include<iostream>
using namespace std;
int main()
{
char *str="I love CHINA";
cout<<str<<endl;
return 0;
}