- 字符串连接函数-- strcat(s1, s2)
char s1[30]=”I am ”, s2[]=”a student.”;
strcat(s1, s2);
cout<<s1; //输出I am a student.
- 字符串复制函数-- strcpy(s1, s2)
char s1[30], s2[]=”China”;
strcpy(s1, s2);
cout<<s1; //输出China
- 字符串比较函数-- strcmp(s1, s2)
char s1[30]=”I am ”, s2[]=”a student”;
if(strcmp(s1, s2)<0)cout<<”s1<s2”;
else cout<<”s1>=s2”; //输出s1<s2
- 字符串长度函数-- strlen(s)
char s[30]=”China”;
cout<<strlen(s); //输出5