字符串处理函数

来源:互联网 发布:出售博客源码违法吗 编辑:程序博客网 时间:2024/06/10 13:20
#include <stdio.h>
#include <math.h>
#include <ctype.h>
#include <string.h>
int main()
{
    char p[] = "ABC";
    char p1[] = "abc";
    char s[] = "tom";
    char s1[] = "";
    printf("%s\n",strlwr(p));//转成小写
    printf("%s\n",strupr(p1));
    printf("%s\n",strcpy(s1,s));//s复制到s1
    printf("%s\n",strncpy(s1,s,1));//1个字节
    printf("%d\n",strcmp(s,s1));//判断大小
    printf("%d\n",strncmp(s,s1,2));//取前2个字符串作为字串判断大小
    printf("%d\n",stricmp(s,s1));//判断大小忽略大小写
    printf("%d\n",strlen(s));//
    printf("%s\n",strcat(s1,s));//把s添加到s1末尾
    printf("%s\n",strncat(s1,s,2));//把s前n个添加到s1末尾
    printf("%s\n",strrev(s));//颠倒
    //printf("%s\n",memcpy(s,s1,2));//颠倒


    return 0;
}
原创粉丝点击