Monday, April 1, 2013

The stars function: a void function without argument

A function that displays a line of stars on the screen.

/* A user-defined function without argument nor result */
#include <stdio.h> /* the function definition */ void stars (void) { printf ("********************************\n"); } /* end of function definition */ /* main program */ int main (void) { printf ("The line of stars comes from a function.\n"); /* calling the function */ stars (); /* the function can be called as will*/ printf ("\n"); stars (); printf ("Hello world!\n"); stars (); return (0); }
Legend: preprocessor directives | variable declarations | main program | helper functions | user-defined structures | comments
The line of stars comes from a function.
********************************

********************************
Hello world!
********************************

No comments:

Post a Comment