c strncpy函数代码实现

char  * Mystrncpy(char * dest, const char *src,size_t count)
{
    char *temp = dest;
    while (count&(*dest++ = *src++)) {
        count--;
    }
    if (count)
    {
        while (--count)
            *dest++ = '\0';
    }
    return temp;
}

 

posted @ 2021-04-12 17:52  紅人  阅读(215)  评论(0编辑  收藏  举报