© Mikael Olsson 2019
Mikael OlssonModern C Quick Syntax Referencehttps://doi.org/10.1007/978-1-4842-4288-9_10

10. Functions

Mikael Olsson1 
(1)
Hammarland, Länsi-Suomi, Finland
 

Functions are reusable code blocks that will only execute when called. They allow developers to divide their programs into smaller parts that are easier to understand and reuse.

Defining Functions

A function can be created by typing void followed by the function’s name, a set of parentheses containing another void, and a code block. The first use of the void keyword specifies that this function will not return a value. The second void inside the parentheses means that the function does not accept any arguments.
void myFunction(void) {
  printf("Hello World");
}

Calling Functions ...

Get Modern C Quick Syntax Reference: A Pocket Guide to the Language, APIs, and Library now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.