Static functions in C

A static function in C is a function that has a scope that is limited to its object file. This means that the static function is only visible in its object file.

default storage class of function global.

There are two files main.c and untitled.c. The contents of these files are given as follows:

Contents of main.c

Contents of untitled.c

In above program without static function it can execute but whenever that function make static that function access with in file only can not access another file .

A program that demonstrates static functions in C is given as follows:

The output of the above program is as follows:

“Hello word”

In the above program, the function fun() is a static function that prints ” Hello word”. The main() function calls fun(). This program works correctly as the static function is called only from its own object file.

Leave a comment