I wrote a simple C program that allocates memory for a row vector, and then prints this.
#include <stdio.h>
#include <string.h>
int main() {
char str_a[20];
strcpy(str_a, "Hello, world!\n");
printf(str_a);
}
Using the compiler gcc, this gives a compilation error:
char_array2.c:8:12: warning: format string is not a string literal
(potentially insecure) [-Wformat-security]
printf(str_a);
1 warning generated.
I do not understand why I am getting a warning. Can someone explain this to me?
source
share