int main()
{
int main=5;
printf("%d",main);
return 0;
}
In this case there is no error and the gcc compiler prints 5. But if I write
int main()
{
int printf=5;
printf("%d",printf);
return 0;
}
the compiler shows an error..why ?
In your first code snippet, you declare a local variable main, which is in the local scope, so it has no effect on the global scope (where the main() function is declared)
In the second code snippet, you declare “printf” in global scope, where the printf() function lives, so you have a conflict.