当用一个字符数组作为字符串的缓冲区时,在定义数组时一定要初始化为0.
否则会提示C6054警告.
1 #include <stdio.h> 2 #include <string.h> 3 #define MAX_LENGTH 10 4 5 int main(void) 6 { 7 char str[MAX_LENGTH] = { 0 }; 8 scanf_s("%s", str, MAX_LENGTH); 9 size_t len = strlen(str); 10 printf("str = [%s]\n", str); 11 printf("len = %u\n", len); 12 return 0; 13 }
标签:C6054,MAX,终止符,len,LENGTH,str,字符串 From: https://www.cnblogs.com/kaling/p/17121699.html