1、函数原型
#include <stdio.h> char *strncpy(char *s1, const char *s2, size_t n) { char *tmp = s1; while(n) { if(!(*s1++ = *s2++)) //此处是if语句,不能用while、for等,此句要和n--;同步执行 break; n--; } // 当字符串str2大于n时,s1指针最后指向的并不是null, 况且当 str2小于n时,指针最后已经指向了null, 为什么还要 执行*s1++ = ' '呢? 程序是否有问题??? while(n--) *s1++ = '