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

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

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

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