Run C as a script, recompiling only when changed
Hot on the heels of a great tip on running C code as a script, I modified it a bit to recompile only when the file changes. It uses the TMPDIR
envvar instead of mktmp
.
//bin/cat /dev/null; mkdir -p $TMPDIR; HASH="`md5sum 0ドル`"; FILE="$TMPDIR/0ドル_$HASH"; gcc -o "$FILE" "0ドル" && "$FILE" "$@"; exit
#include <stdio.h>
int main(int argc, char *argv[]) {
int i;
printf("Arguments:\n");
for (i = 0; i < argc; i++) {
printf("%d: %s\n", i, argv[i]);
}
}
Written by Colin Dean
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Shell
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#