Insert Function before and after main function

2781 단어 function
Source code:
   1: #include<stdio.h>
   2: void myStartupFun (void) __attribute__ ((constructor));
   3: void myCleanupFun (void) __attribute__ ((destructor));
   4:   
   5: /* implementation of myStartupFun */
   6: void myStartupFun (void)
   7: {
   8:     printf ("startup code before main()
"
);
   9: }
  10:  
  11: /* implementation of myCleanupFun */
  12: void myCleanupFun (void)
  13: {
  14:     printf ("cleanup code after main()
"
);
  15: }
  16:  
  17: int main (void)
  18: {
  19:     printf ("hello
"
);
  20:     return 0;
  21: }

 
Just compile the source code, and run, you will find the interesting result.

좋은 웹페이지 즐겨찾기