The Structure of a C Program

//***************************************************************************************

//* Title: helloWorld.c Author: N. Bercich

//*

//* This program displays the phrase, "Hello World" on the terminal.

//***************************************************************************************

#include <stdio.h>

main()

{

printf("Hello, world\n");

}

Compiling and Executing a C Program on UNIX

gcc <filename> -o <outputfilename>

  • This will create an executable with the name outputfilename. If you forget to use the –o option when compiling your code, your executable will be named a.out.
  • Other options are available with gcc. You are free to use those you find useful as your C and UNIX skills improve. Initially, stick with just the one.
  • To execute a C program on UNIX enter the following after the prompt:
  • ./outputfilename

  • An optional parameter list may follow the outputfilename.
  • Exercise