Leaflets

22 August, 2011

Call A Function Before main() in C

Can you call a function before main()
Yes you can do so by using #pragma directive
#pragma startup provides you this feature
just give you function a priority and it will be executed before main()
//code///
#include<stdio.h>
void main(void)
{
printf("hi i m main");
}
void fun(void);
#pragma startup fun 60
void fun(void)
{
printf("hi i m fun\n");
}

No comments:

Post a Comment