Linux

  1. Home
  2. Computing & Technology
  3. Linux

Linux Newbie Administrator Guide

From Authors, for About.com

8.2.5 C

gcc filename.c

GNU C compiler. Quite straight-forward if you know C. Extensive free manuals are available on the net.

How do I compile a simple C program?

Start your favourite text editor and type in your source code. For example, I may use pico:

pico hello.c

and type in the Kerningham and Richie (the creators of "c") intro example of a C program:

#include <stdio.h>

void main(void) {

printf("hello world\n") ;

}

I save the file and then invoke the GNU C compiler to compile the file "hello.c":

gcc hello.c

The gcc compiler produces an executable binary file "a.out", which I can run:

./a.out

* License

* Linux Newbie Administrator Guide Index

Explore Linux

About.com Special Features

Linux

  1. Home
  2. Computing & Technology
  3. Linux
  4. Linux Documentation
  5. Newbie Administrator Guide
  6. Linux Newbie Administrator Guide - 8.2 Simple Programming under Linux

©2009 About.com, a part of The New York Times Company.

All rights reserved.