1.

How to call a function before main()?

Answer»

To call a FUNCTION before the MAIN(), pragma startup directive should be used. E.g.-

#pragma startup funvoid FUN(){printf("In fun\n");}main(){printf("In main\n");}

The output of the above program will be -

In funIn main

This pragma directive, on the other hand, is compiler-dependent. This is not SUPPORTED by gcc. As a result, it will ignore the startup directive and produce no error. But the output, in that case, will be -

In main


Discussion

No Comment Found