C常用函数的实现

来源:互联网 发布:ps机做淘宝主图多 编辑:程序博客网 时间:2024/05/29 04:48

//strcat实现
char* _strcat(char *s, char *t)
{
     char *address = s;
     assert(s != NULL && t != NULL);
     while (*address)
     {
           ++address;
     }
    
     while(*address++ = *t++)
           ;
     return address;
}

//t是否在s尾部出现
int strlend(char *s, char *t)
{
     int sLength = strlen(s);
     int tLength = strlen(t);
     if(sLength < tLength)
                return 0;
     if(!tLength)      return 1;
    
     return !strcmp(&s[sLength - tLength], t);
}

原创粉丝点击