I copied this below code from Stack Overflow's 404 Not Found Error Page.
# define v putchar
# define print(x)
main(){v(4+v(v(52)-4));return 0;}/*
#>+++++++4+[>++++++<-]>
++++.----.++++.*/
print(202*2);exit();
#define/*>.@*/exit()
The above code compiles fine and prints 404 on the console. I thought the statement print(202*2); is responsible for printing 404, but I am not right because changing the numbers in this statement also prints 404.
Could somebody help me to understand this code and how it prints 404?
Am posting the compilation output for your reference as there are comments saying this code doesn't compile. The file containing above code is Test.c.
gcc Test.c -o Test
Test.c:3:1: warning: return type defaults to ‘int’ [-Wimplicit-int] main(){v(4+v(v(52)-4));return 0;}/* ^ Test.c: In function ‘main’: Test.c:1:12: warning: implicit declaration of function ‘putchar’ [-Wimplicit-function-declaration] # define v putchar ^ Test.c:3:8: note: in expansion of macro ‘v’ main(){v(4+v(v(52)-4));return 0;}/* ^ Test.c: At top level: Test.c:6:14: warning: data definition has no type or storage class print(202*2);exit(); ^ Test.c:6:14: warning: type defaults to ‘int’ in declaration of ‘exit’ [-Wimplicit-int] Test.c:6:14: warning: conflicting types for built-in function ‘exit’
./Test
404