cheader-files

main or header file which will compiler execute first?


#include<stdio.h>
int main()
{    
    printf("hi");    
}

which will be executed first main or header file?

does main program will execute first and include the contents of header file?


Solution

  • #include means textual insertion of the file at exactly the line where the #include is found. That is done by the preprocessor, so the compiler doesn't see the #include command itself anymore. In your case that means that first all code from stdio.h is compiled and then your function main(). But nevertheless program execution always starts with main()