Hi Can anybody tell me

What is the usage of Static functions and where we can use

what is the advantage of Static functions over Normal functions


Advance Thanks for helping

Recommended Answers

All 4 Replies

>What is the usage of Static functions and where we can use
static functions have a visibility restricted to the translation unit in which they're declared. You can use them anywhere a regular function can be used, but you should use them everywhere you can because they follow the rule of minimal scope.

If you have a small program with just one *.c file, then static functions aren't all that useful. The advantage of statics is with larger programs whose projects consist of several *.c files. In this case, as Narue already said, make all the functions static that do not need global scope to other *.c files. And the same with global data objects, make them static too if they don't need to be referenced in more than one *.c file.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.