Can static variables be declared in a header file?



Can static variables be declared in a header file?..

Answer / Prem Sagar

No, static variables cannot be directly declared in a header file. Static variables have internal linkage, meaning they exist only within the source file where they are defined. However, you can declare them as `extern static` in the header file and define them in each corresponding source file.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

What is a floating point in c?

1 Answers  


Why main function is special give two reasons?

1 Answers  


What is sizeof return in c?

1 Answers  


How can I read data from data files with particular formats?

1 Answers  


What is assignment operator?

1 Answers  


write a program to display the numbers having digit 9 in the given range from 1 to 100

1 Answers  


1 What is a Data Structure?

1 Answers  


What is build process in c?

1 Answers  


When should a type cast not be used?

1 Answers  


Can a function be forced to be inline? Also, give a comparison between inline function and the C macro?

0 Answers   Genpact,


What is the best way to store flag values in a program?

1 Answers  


In which category does main function belong??

5 Answers  


Categories