Q. I am new to Linux but not to c programming. At university we are using Turbo C compiler under DOS/Windows XP to write and compile C programs. Under Linux Iâ€™ve small program called test.c. How do I compile and see the output of C program in Linux? Note Iâ€™m using Fedora Core Linux.
A. Under Linux you need to gcc (GNU project C and C++ compiler) command to compile a program. When you compile a program it generates an executable file called a.out.
gcc -o output-file program.c
Task: Compile program
To compile type the command:
$ gcc test.c
Task: Execute program to see output
Above command will create a file called a.out. To see output of test.c program type:
Task: Compile to specific executable file
You can specify an execuable file name while compiling program itself:
$ gcc -o test test.c
Now execute test (see output of test.c)