5-3

来源:互联网 发布:ubuntu安装vlc播放器 编辑:程序博客网 时间:2024/05/02 11:26
#include <stdio.h>
#include <stdlib.h>
/*
用指针方式实现strcat.strcat(s,t)将t指向的字符串复制到s指向的字符串尾部
*/
int strcat(char *s,char *t)
{
    if( s==NULL)return -1;
    while(*s!='/0')
    s++;
   
    while( *s++=*t++)
    ;
    return 0;
}
int main(void)
{
    char a[1000]={"hello"};
    char *b="world";
    if( strcat(a,b) !=0)
        return -1;
    printf("a is :%s",a);
    system("pause");
    return 0;
}    
原创粉丝点击