I have read the code like the one down below in an obfuscated program.
I wonder why the compiler gave me an warning instead of an error when I doing like this. What the code really want to do and why the compiler suggests me to use an array?
#include <stdio.h>
int main()
{
int f = 1;
printf("hello"+!f);
return 0;
}
warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
printf("hello"+!f);
~~~~~~~^~~
note: use array indexing to silence this warning
printf("hello"+!f);
^
& [ ]
See Question&Answers more detail:os