O'Reilly logo

C Programming: Visual Quickstart Guide by Marc Liyanage, Larry Ullman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required