strncpy_s函数原型是
errno_t strncpy_s(
char *strDest,
size_t numberOfElements,
const char *strSource,
size_t count
);
你这里调用错了
https://msdn.microsoft.com/en-us/library/5dae5d43.aspx
# include
# include
int main()
{
char str6[30] = "beijing";
char str7[20] = "love";
strncpy(str6, str7, 3);
for (int i = 0; i < 30; i++)
{
printf("%c", str6[i]);
}
printf("%s",str6);
printf("%c", str6[5]);
}