C语言编程问题,Microsoft visual studio 2017版出现

2025-03-20 18:00:57
推荐回答(2个)
回答1:

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

回答2:

# 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]);
}