在C++程序中如何使用字符串函数?
1、字符串连接函数strcat 它的作用是把第二个字符数组中的字符串连接到第一个字符数组的字符串的后面。
#include <iostream>
using namespace std;
int main()
{
char s1[]="We all like ";
char s2[]="freedom";
cout<<strcat(s1,s2)<<endl;
return 0;
}

2、字符串复制函数strcpy 它的作用是把第二个字符数组中的字符串复制到第一个字速鉴符数组中去,替代第一个字符数组中的相应字符。
#include <iostream>
using namespace std;
int main()
{
char s1[8];
char s2[]="freedom";
cout<<strcpy(s1,s2)<<endl;
return 0;
}

3、 爱物哄字符串比较函数strcmp 它的作用是比较第二个字符数组中的字符何施串和第一个字符数组中的字符串。
#include <iostream>
using namespace std;
int main()
{
char s1[]="We all like ";
char s2[]="freedom";
cout<<strcmp(s1,s2)<<endl;
return 0;
}

4、比较规则是自左至右逐个比较,直到出现不同的字符或者遇到’\0’为止。

5、应用字符串比较函数时,如果字符串1等于字符串2,返回值为0

6、应用字符串比较函数时,如果字符串1大于字符串2,返回值为1

7、应用字符串比较函数时,如果字符串1小于字符串2,返回值为-1
