Reputation: 3761
I want to run single C files with a single command, just like we can run any python file example.py
with the command-
python example.py
I cannot find any GCC or Make command or even any script (in linux) to do this. I want to run any C file example.c
with the some command like-
crun example.c
and then the single C file will compile and run. I don't bother if some other files are created in the process. Is there any command or script for this?
Upvotes: 0
Views: 198
Reputation: 132
You can use a c language interpreter.
Like cint(CINT is an interpreter for C and C++ code.):
https://root.cern.ch/drupal/content/cint
This c interpreter (https://github.com/kazuho/C) is also good.
You can do things like this:
root@foo ~:c -e 'printf("hello")'
root@foo ~:hello
Or for something like ipython you can try this:
http://da.vidr.cc/projects/iccsh/
Upvotes: 1
Reputation: 5163
Something like this?
#!/bin/sh
OUT="$(mktemp)"
rm $OUT
gcc -o $OUT $1 && ( shift ; $OUT $* )
rm -f $OUT
Upvotes: 2