Node:Example comment, Next:, Previous:Comments, Up:The form of a C program



Example 1


#include <stdio.h>      /* header file */

main ()   /* Trivial program */

{

/* This little line has no effect */
/* This little line has none */
/* This little line went all the way down
   to the next line,
   And so on...
   And so on...
   And so on... */

  do_little();

  printf ("Function 'main' completing.\n");
}

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

/* A bar like the one above can be used to */
/* separate functions visibly in a program */


do_little ()
{

/* This function does little. */

  printf ("Function 'do_little' completing.\n");
}

Again, this example is old-fashioned C, and in mediocre style. To make it more compliant with the ANSI Standard and GNU guidelines, we would declare the variable type each function returns (int for main, which also requires an exit or return statement), and we would create function prototypes at the beginning of the file. (See Functions.)