#include<stdio.h>
int main(){
int main =22;
printf("%d\n",main);
return 0;
}
output:22 I am defining main as function and variable both even though compiler is not giving error. It should give error "error: redefinition of ‘main’ " . I am not able to understand why this code is working.
It will not give you an error because main
is not a keyword. but main is define 2 times
- Scoping rules come into play.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With