What really happens when I compile int main; in C

What really happens when compiling:

int main; 

Is this supposed to main () and caused the error?

I tried to compile the code in CodeBlocks and compiled without errors.

+5
source share
2 answers

This is not an error, since the C source file should not have a function main, and you can define it mainas you wish, if you are not trying to define it twice in the same area. Since this is your whole program, this is good, but the program will certainly work incorrectly. since there is no function mainto search.

, , () main, 0. , , ( , ).

EDIT: , , , main 0, . , , 0, segfault .

+6

, - ( ) .

, int main;, , . , , .

, , , .

:

int main;

int main()
{
  printf("In main\n");
}

, main , int main, 5.

int main()
{ 
   int main = 5;
   printf("In main, value of main is %d\n", main);
}

int main()
{
       printf("In main, value of main is %d\n", main);
}

EDIT: , , , , "C". , int main;, , , , main , , , , , .

, C

+3

All Articles