I have been trying to run a c code from my terminal. The command:
gcc abc.c
is not giving any output and instead it gives me a new command line without any messages.
When I try
python3 abc.py
the code runs and I get the output. I have tried many different c codes and I am not getting any error messages or the output of the code in all of them. I am sure that I have gcc installed as gcc --version
shows me the version. So I don’t have any idea what is wrong right now.
Note: I haven’t run any c code before I am just trying to set the compiler up and run a c code from the terminal.
syglon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
4
Type gcc
only and if you get fatal error about no input files it is most probably installed correctly.
Make sure the terminal is opened in the directory of the input file (c program).
It usually doesn’t returns any message if the program is correct. It usually creates a .exe file(in Windows) or .out(In Mac and Linux) and you have to run that file to get the output.
Commands:
gcc <Input File Name> -Wall -o <Output File Name>
explanation: -Wall is to get any warnings from compiler about your program(remove if you want to)
-o tag is used to specify the output file (.out or .exe) name
and after all this type
<name of the file with extension>
Example:
gcc myProgramBlaBlaBla.c -Wall -o myFile
and then
myFile.exe
(If you use windows) or myFile.out
(If you don’t use windows)
2