.
首先要引入字符串的库或,之后就能直接调用库里的方法和函数
.
声明字符串:
char str[num];
string str;
对已经声明过的字符串变量进行赋值:
str[100]="helloworld!";
str = "helloworld1"
复制第二个字符串到第一个字符串:strcpy(str1,str2),该方法不能直接输出
char str1[10] = "say";
char str2[10] = "hello";
strcpy(str1,str2);
//str1 = "hello"
连接两个字符串:strcat(str1,str2),该方法不能直接输出,新字符串的值被赋予到了第一个字符串
也可以使用 " + " 连接:str1+str2 / str1+ " " +str2
char str1[10] = "say";
char str2[10] &#