C - Function Static Functions


You can ensure that a function is only visible within the source file in which you define it by declaring it as static.

For example:

static double average(double x, double y) { return (x + y) / 2.0; }

This function can only be called in the .c file in which this definition appears.

Without the static keyword, the function could be called from any function in any of the source files that make up the program.

You can apply the static keyword in a function prototype and the effect is the same.