strncpy

char* mstrncpy(char *dest, const char *src, size_t n){
    size_t i;
    size_t j=n-1;
    for (i = 0 ; i < j && src[i] != '\0' ; i++)
        dest[i] = src[i];
    dest[i] = '\0';
    
    return dest;
}

 

posted on 2019-01-10 14:49  阮減显  阅读(134)  评论(0编辑  收藏  举报

导航