strcpy()函数

strcpy()函数声明与实现

char *strcpy(char *dst, const char * src)

char *strcpy(char *dst, const char *src)

{

    if((dst==NULL)||(src==NULL))

        return NULL;

    char *ret = dst;

    while((*dst++=*src++)!='\0');

    return ret;

}

strcpy只用于字符串复制,并且它不仅复制字符串内容,还会复制字符串的结束符。

dst和src应该满足下面的条件

    sizeof(dst)>=sizeof(src)+1

猜你喜欢

转载自blog.csdn.net/pekingFloater/article/details/81062920