I've found this C program from the web:
#include <stdio.h>
int main(){
printf("C%d\n",(int)(90-(-4.5//**/
-4.5)));
return 0;
}
The interesting thing with this program is that when it is compiled and run in C89 mode, it prints C89
and when it is compiled and run in C99 mode, it prints C99
. But I am not able to figure out how this program works.
Can you explain how the second argument of printf
works in the above program?
//
comment was introduced in C99.gcc
. Withoutstd=c99
you'll get a warning, and if you ignore it,gcc
will still interpret the//
as start of a comment (ah – you have to use-pedantic
as well. I have that on by default.)C89
with explicitstd=c89
in gcc 4.9.2.#if __STDC_VERSION__ >= 199901L
, not the//
comment trick. =)