Skip to content

Instantly share code, notes, and snippets.

@Gaurav-Singh-97
Created December 2, 2016 17:51
Show Gist options
  • Save Gaurav-Singh-97/2202490f2eb887713249fdccb65c2e6a to your computer and use it in GitHub Desktop.
Save Gaurav-Singh-97/2202490f2eb887713249fdccb65c2e6a to your computer and use it in GitHub Desktop.
Running functions before and after main() (doesn't work on gcc and g++)
#include<stdio.h>
void First();
void Last();
#pragma startup First
#pragma exit Last
void First()
{
printf("B4 main\n");
}
void Last()
{
printf("After main\n");
}
int main()
{
printf("Inside main\n");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment