Running C code in the terminal
I'm learning C, but I can't remember how to run my code, I compile it with tcc xyz.c and that's about it. I can't remember the command I used to run the code when I was learning cpp and I've searched on the internet for answers, but none of the responses answered my question. I'm spoiled by python.
About this post
- Posted
- Archived
- Score
- 0 · 100% up
- Kind
- Text
- ID
- d2ddrl
15 comments
. /binary_name
I don't think that was the command I was looking for, it was something similar, but I can't put my finger on it
C is not interpreted. Once you compile it, you'll get a binary which you can execute - using
./binary_nameas mentionedWhat other command would you expect. When you compile C/C++ code it became an executable, which you can just run and you do it by typing the path to the binary file. If it is located in your current directory then you use
./to tell your shell "use executable from current directory" and by addingbinary_nameyou tell it to run your program, so you just use./binary_nameas u/A9-EE-78-6A-C8-9F has stated. This is the most basic method of all.OPs lack of general comprehension in this thread greatly concerns me...
It’s not even Arch specific... so many questions...
... Is troll, or... ?
Never attribute to malice what can be adequately explained by stupidity
GCC will typically create the executable file
a.outwhen the -o option is omitted, does tcc the same?That's what I was looking for!
./a.outthanks!You should also be able to name the executable using the -o flag.
tcc xyz.c -o xyzI remember not having to use -o, I might be mistaken, but I can't remember.