Creating Simple Functions

Writing your own functions requires following the proper syntax. First, you must create a function prototype—a declaration of a function's name, arguments, and what type of value it returns. This prototype helps the compiler check that the function is properly used in an application. The syntax for the prototype is

					type_returned function_name (arguments);

The type_returned section refers to what sort of value the function will return. For example, the main function returns an integer (0 in all of the book's examples so far). If the function returns no value, its type_returned will be void.

Naming functions follows the same rules as naming variables: you use alphanumeric characters plus the underscore. Also, function ...

Get C Programming: Visual Quickstart Guide now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.