About Linux FAQ

Browse More FAQs:

Howto see output of C program in Linux or UNIX

Posted by Vivek on Monday April 9, 07 @1:21 pm

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:

Discussion on This FAQ

  1. ajay Says:

    yaa
    you help me a lot
    thnx budy

  2. vivek Says:

    hey man thanks for the instruction…… i can now compile and run c programs……

  3. manisha Says:

    this is realy very nice.thanks to help me.

  4. umair Says:

    i have installed MinGW now pls tell how to write a program and excuate it

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!

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Tags: , , , , , , , , , , , , ~ Last updated on: September 15, 2007

Copyright © 2006-2008 nixCraft. All rights reserved - TOS/Disclaimer - Privacy policy - Sitemap - Powered by Open source software.