Question: I just got started writing some C programs.

To start with I was just running them through VS code. Nice and easy, I just had to press a button and bam, there it was.

But now I need to pass files as arguments to my program, which creates the need of running it from the command line.

The way I do it now, is using this two step process, (which I think is just the basic way of doing it):

```
ask@Garsy:~/Notes/ethHack/crpytifiles$ gcc test.c -o test

```

and then running the file:

```
ask@Garsy:~/Notes/ethHack/crpytifiles$ ./test 

```

This is a bit tedious in the long run. Is there any way I could do this process in one step?

And perhaps also without creating the executable?

It would be really cool if I could just run it as you normally would with a python or java file, one command, and the thing runs.

Answer: 
You could do that with a **makefile**. More about **GNU Make** [here](https://www.gnu.org/software/make/).

```
all:
  gcc test.c -o test
  ./test

```

The file should be called **Makefile** or **makefile** *(it can have different names,just keeping it simple)*, and you can run it by executing:

`make`

Assuming you have `GNU Make` installed and `test.c` is located in the same directory with `makefile`.
> 
> This is a bit tedious in the long run. Is there any way I could do this process in one step?
> 
> 
> 

Yes. You could create a shell function (or an alias if your shell supports alias arguments, which bash does not), e.g.:

```
ccr() { gcc "$1" -o x.$$ && ./x.$$; rm -f x.$$ }

$ ccr hello.c
Hello, world!
$

```

which will compile the script, run it if compilation succeeded, then remove the compiled binary.

> 
> And perhaps also without creating the execuable?
> 
> 
> 

No (well, not easily). Executing binaries is offloaded to the `exec*()` function family, and the operations performed are complex and, I suspect, incompatible with stdin operations. So you cannot send the executable to a pipe and execute it from the pipe.

What you can do is use a [C interpreter](https://stackoverflow.com/questions/584714/is-there-an-interpreter-for-c), albeit it is not exactly the same thing.