Last active
March 16, 2019 05:19
-
-
Save a2gs/2d0e6750c9ce15edc92329d3b5682185 to your computer and use it in GitHub Desktop.
exit() vrs return() into main()
This file contains 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> | |
#include <stdlib.h> | |
static char *message; | |
void cleanup(void) | |
{ | |
printf("message = \"%s\"\n", message); | |
} | |
int main(int argc, char *argv[]) | |
{ | |
char local_message[] = "hello, world"; | |
message = local_message; | |
atexit(cleanup); | |
#ifdef USE_EXIT | |
puts("exit(0);"); | |
exit(0); | |
#else | |
puts("return 0;"); | |
return 0; | |
#endif | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output:
Code from: https://qr.ae/TWR8Ez
Thanks!