字符串函数运用

    xiaoxiao2021-03-25  14

    #include<stdio.h> #include<string.h> #include<ctype.h> int main () { char c1[50] = {"123"}; char c2[50] = {"123456"}; char c3[50] = {"456"}; char c4[50] = {"abc"}; strcpy(c2,c1); //把c1 复制给 c2 puts(c2); strcat(c3,c1); //连接c3 c1 c3 在前 puts(c3); printf("%d\n",strcmp(c1,c3)); //c1 < c3 printf("%d\n",strlen(c1)); strupr(c4); //变成大写 puts(c4); strlwr(c4); //变成小写 puts(c4); printf("%d %d %d %d\n", isalnum('1'), isalnum('A'), isalnum('a'), isalnum('-')); //判断是否是字母或数字。yes return > 0 printf("%d %d %d %d\n", isalpha('1'), isalpha('A'), isalpha('a'), isalpha('-')); //判断是否是字母。yes return > 0 printf("%d %d %d %d\n", islower('1'), islower('A'), islower('a'), islower('-')); //判断是否是小写字母。yes return > 0 printf("%d %d %d %d\n", isupper('1'), isupper('A'), isupper('a'), isupper('-')); //判断是否是大写字母。yes return > 0 return 0; }
    转载请注明原文地址: https://ju.6miu.com/read-200148.html

    最新回复(0)