Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

The GNU C Programming Tutorial - Example 1

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.)

 
 
  Published under free license. Design by Interspire