Created
October 11, 2018 10:55
-
-
Save ljmccarthy/4a42c0971694ab2763def37ae70327d6 to your computer and use it in GitHub Desktop.
Self-compile and run C file. chmod +x and ./run it!
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
#if 0 | |
set -e | |
[ -z "$CC" ] && CC=$(which tcc clang gcc cc | head -1) | |
out="$(tempfile -p $(echo $(basename $0) | cut -f 1 -d '.'))" | |
$CC -pipe -x c -std=c99 -g -ftrapv -o $out "$0" | |
exec $out "$@" | |
#endif | |
#include <stdio.h> | |
int main(int argc, const char *const *argv) { | |
remove(argv[0]); | |
printf("hello, world!\n"); | |
for (int i = 0; i < argc; i++) { | |
printf("argv[%d] = %s\n", i, argv[i]); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment