Curiously, I did not expect this to compile, but it is. However, the compiler does not really like this:
..\main.c:4:7: warning: type defaults to 'int' in declaration of 'VARNAME'
..\main.c:4:17: warning: initialization makes integer from pointer without a cast
Thus, it accepts the int type by default, and therefore, the VARNAME value has a pointer value, since the string is a pointer (which may later be distinguished as char *).
This works fine (on Intel IA32 machine):
#include<stdio.h>
const VARNAME = "String of text";
int main()
{
printf("%s\n", (char*)VARNAME);
return 0;
}
But I personally would not use such implicit typing. As explained below:
this is even dangerous since sizeof (int) may be smaller than SizeOf (char *)