C语言中字符串处理函数实现(部分)

int mystrlen(char *a)//求字符串长度

{

    int b=0;

    while(*a)

    {

        b++;

        a++;

    }

    return b;

}

char *mystrcpy(char *d,const char *stc)//复制字符串

{

    while (*stc) {

        *d=*stc;

        stc++;

        d++;

    }

    d='\0';

    return &d[0];

}

char itoh (int i)//十六进制数转字符串

{

    if (i>9) {

        return i-9+'A';

    }

    return i+'0';

}

int mycomputy(char *a,char *b)//比较字符串

{

    while (*a||*b)

    {

        if (*a>*b)

        {

            return 1;

        }

        else if(*a<*b)

        {

            return -1;

        }

        a++;

        b++;

    }

        return 0;

}

char *lianjie(char *a,char *b)//链接字符串

{

    while (*a++) ;

    a--;

    while ((*a++=*b++));

    return a;

}

    

posted on 2014-09-23 20:17  陈丰波  阅读(158)  评论(0编辑  收藏  举报