Last active
December 25, 2021 23:32
-
-
Save opsJson/f1d41caf72ac93b32c8e031a6df5d93f to your computer and use it in GitHub Desktop.
Execute code before and after main function.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
void before_main() { | |
printf("code before main here.\n"); | |
} | |
void after_main() { | |
printf("code after main here.\n"); | |
} | |
int __main__(int argc, char **argv); | |
int main(int argc, char **argv) { | |
before_main(); | |
__main__(argc, argv); | |
after_main(); | |
} | |
#define main(...) __main__(int argc, char **argv) | |
/*/////////////////////////////////// | |
Testing: | |
///////////////////////////////////*/ | |
int main() { | |
printf("Hello World\n"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment