Skip to content

Instantly share code, notes, and snippets.

@meuter
Created June 16, 2018 09:38
Show Gist options
  • Save meuter/66541878670e4e2133dad8299c5505c6 to your computer and use it in GitHub Desktop.
Save meuter/66541878670e4e2133dad8299c5505c6 to your computer and use it in GitHub Desktop.
Using shebang to compile and run C program directly
//usr/bin/gcc -o test "$0" && exec ./test "$@"
#include <stdio.h>
int main(int argc, const char *argv[])
{
int i;
for (i = 0; i < argc; i++)
printf("argv[%d] = '%s'\n", i, argv[i]);
return 42;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment