Q:

What are the uses of the keyword static?

0

What are the uses of the keyword static?

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Answer:

In C language, the static keyword has a lot of importance. If we have used the static keyword with a variable or function, then only internal or none linkage is worked. I have described some simple use of a static keyword.

1.  A static variable only initializes once, so a variable declared static within the body of a function maintains its prior value between function invocations.

2.  A global variable with static keyword has internal linkage, so it only accesses within the translation unit (.c). It is not accessible by another translation unit. The static keyword protects your variable to access from another translation unit.

3. By default in C language, the linkage of the function is external that it means it is accessible by the same or another translation unit. With the help of the static keyword, we can make the scope of the function local, it only accesses by the translation unit within it is declared.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
What are the different types of linkage?... >>
<< What are the data types in C?...