char str1[20] = {0};
const char *str2 = "Hello world!";
strncpy(str1, str2, sizeof(str1) - 1);
str1[sizeof(str1)-1] = '\0';
C语言复制字符串
最新推荐文章于 2023-03-29 21:48:30 发布
char str1[20] = {0};
const char *str2 = "Hello world!";
strncpy(str1, str2, sizeof(str1) - 1);
str1[sizeof(str1)-1] = '\0';