Howto see output of C program in Linux or UNIX
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.
Syntax
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:
$ ./a.out
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)
$ ./test
Subscribe to our free e-mail newsletter or RSS feed to get all updates.
You can Email this page to a friend.
Related Linux / UNIX FAQ:
- Howto Compiling C program and creating executable file under Linux / UNIX / *BSD
- Open MS-Word and MS-PowerPoint file under Linux/UNIX
- FreeBSD admin book / handbook
- How do I install and search FreeBSD ports or a package?
- UNIX File Encryption howto
Discussion on This FAQ
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Please do not use the comment form to ask for help / question. Ask your question on the excellent Linux tech support forum. Thank you very much for stopping by our site!
Tags: compiling_program, c_program, c_programming, c_programs, c_test, executable_file, fedora_core, gcc_gnu, Linux, program_c, project_c, test_c, turbo_c_compiler ~ Last updated on: September 15, 2007



May 25th, 2007 at 4:38 am
yaa
you help me a lot
thnx budy
June 4th, 2007 at 6:18 pm
hey man thanks for the instruction…… i can now compile and run c programs……
September 15th, 2007 at 11:05 am
this is realy very nice.thanks to help me.
January 22nd, 2008 at 5:50 pm
i have installed MinGW now pls tell how to write a program and excuate it