概括
代码
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
int main()
{
char a[]="abcSDFbnm";
char b[]="SD";
printf("a的字符串长度:%d\n",strlen(a));
printf("b的字符串长度:%d\n",strlen(b));
printf("a与b比较:a=b返回0;a<b返回小于0;a>b返回大于0:%d\n",strcmp(a,b));
char *p1=strchr(a,'b');
printf("a中查找b:%s\n",p1);
char *p2=strstr(a,b);
printf("a中查找b:%s\n",p2);
char *p3=strcat(a,b);
printf("a连接b的内容:%s\n",p3);
printf("a复制b的内容:%s\n",strcpy(a,b));
getchar();
return 0;
}
输出
a的字符串长度:9
b的字符串长度:2
a与b比较:a=b返回0;a<b返回小于0;a>b返回大于0:1
a中查找b:bcSDFbnm
a中查找b:SDFbnm
a连接b的内容:abcSDFbnmSD
a复制b的内容:SD
|