c - run C code fragments from the commandline. Usage: c [] [] The c utility wraps a bare-bones C program around the C source code fragments specified by the user, compiles the program, runs the program with passed to it on its command line, and then removes the temporary files it created (the C source file and the executable). Options: -h or --help Show this usage message and exit. -i= -I= Add an #include for the given filename. ".h" will be appended to the filename unless it already ends in ".h" or ".c". By default it will be included with <>-brackets, eg: -I=foo produces '#include ', but if foo is enclosed in ""'s it will be included with quotes, eg: -I='"foo"' produces '#include "foo.h"'. -f='...' -F='...' Prepends a function before declaring main(). For instance: c -f='int foo(){return 1;}' 'printf("%d\n",foo());' --cflags='..' --CFLAGS='..' Override the default arguments sent to gcc. By default the arguments are: "-I. -O0". Alternatively, set the CFLAGS environment variable (which would be overridden by using this command line option). -r Show the exit code after all other output. --save-temps Do not delete temporary files (in /tmp). Note: By default, "stdio.h", "stdlib.h", "string.h", "unistd.h", and "time.h" will be #include'd for you (since these are so commonly used). Note: The main function is declared as: int main(int ac, char *av[]) Note: -std=gnu99 is always passed to gcc, and there is nothing you can do about it (except modifying this script, which I would encourage). Examples of use: # ./c 'for(int i = 1; i <= ac; i++){printf("%s\n", av[i]);}' ichi ni san shi re ichi ni san shi re # ./c 'for(int i = 0; i < 4; i++){printf("meow\n");}' --save-temps meow meow meow meow # cat /tmp/clip13282.c #include #include #include #include #include int main(int ac, char *av[]) { for(int i = 0; i < 4; i++){printf("meow\n");} }