Derived from: https://news.ycombinator.com/item?id=9145279
Just put this on the first line of your C file:
//usr/bin/env make -s "${0%.*}" && ./"${0%.*}" "$@"; s=$?; rm ./"${0%.*}"; exit $s
Then just do chmod u+x ./main.c; ./main.c
.
Make sure there isn't a directory that has the same name as your C file name, otherwise it won't work.
If you can combine this with nix-shell
shebang you might even get a package manager for free too!