#include<stdio.h>
int main()
{
const char arr[10] = "hello";
printf(arr);
return 0;
}
When compiling the above code with don't gave any warning. But when I remove the
const
from const char arr[10]
it gives a warning:
<source>: In function 'main':
<source>:5:10: warning: format not a string literal and no format arguments [-Wformat-security]
5 | printf(arr);
|
为什么我会变成这样?const
个关键词有什么不同?我在这里用gcc -Wformat -Wformat-security …
.