#include <iostream>
#include<string.h>
using namespace std;
int main()
{
char str1[11],str2[11];
char str3[]="hello";
char str4[]="GoodBye";
strcpy(str1,str3); //调用strcpy函数,将str3的内容复制给str1;
strcpy(str2,str4);
int ch=strcmp(str4,str3); //比较两个字符串
int len=strlen(str4); //字符串的长度
strcat(str4,str3); //将两个字符串连在一起
cout<<"str2="<<str2<<endl;
cout<<"str1="<<str1<<endl;
cout<<"str4="<<str4<<endl;
cout<<"len="<<len<<endl;
if(ch==0)
{
cout<<"str4"<<"等于"<<"str3"<<endl;
}
else if(ch>=0)
{
cout<<"str4"<<"大于"<<"str3"<<endl;
}
else if(ch<=0)
{
cout<<"str4"<<"小于"<<"str3"<<endl;
}
return 0;
}
样例: