CHAPTER 10

image

Functions

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

The previous function will print out a text message ...

Get C Quick Syntax Reference 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.