标签:字符数组基本操作
#include <stdio.h>
#include <string.h>
void main(){
/**
char ch[]="china\nbeijin";
char ca=‘a‘;
char c[12];
gets(c);
puts(ch);
puts(c);
*/
char ch1[30]={"china beijing"};
char ch2[]={"CaoYangQu"};
char ch3[30];
//字符数组连接,ch2连接到ch1
//strcat(ch1,ch2)
printf("%s\n",strcat(ch1,ch2));
//字符数组拷贝,ch1拷贝到ch3
//strcpy(ch3,ch1);
strcpy(ch3,ch1);
printf("%s\n",ch3);
//字符数组的比较.ch1>ch2,返回正数;ch1<ch2,返回负数;ch1=ch2,返回零
//strcmp(ch1,ch2)
printf("%d\n",strcmp(ch1,ch2));
//字符数组的长度
//strlen(ch1)
printf("%d\n",strlen(ch1));
//字符数组变小写
//strlwr(ch2)
//字符数组变大写
//strupr(ch2)
printf("%s\n",strlwr(ch2));
printf("%s\n",strupr(ch2));
}
标签:字符数组基本操作
原文地址:http://cbg23.blog.51cto.com/7201812/1618823