How to circumvent format-truncation warning in GCC?
问题 I'm getting the following gcc format-truncation warning: test.c:8:33: warning: ‘/input’ directive output may be truncated writing 6 bytes into a region of size between 1 and 20 [-Wformat-truncation=] snprintf(dst, sizeof(dst), "%s-more", src); ^~~~~~ test.c:8:3: note: ‘snprintf’ output between 7 and 26 bytes into a destination of size 20 snprintf(dst, sizeof(dst), "%s-more", src); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ on code like this: char dst[20]; char src[20]; scanf("%s", src);