If a program is in several source files,the best arrangement is to place eachdefinition in some relevant source(.c) file, with an external declaration of function n variables in a seperate header file that is included by #include at the front of each source file..
The best way to declare and define global variables is to fix your code so you're not using them.
The second best way is to determine whether you mean "file scope" - "global" but only within the given source unit - or actual global, visible to everything.
If it's file scope you're after, define the variable as a static, outside the confines of any function block.
If it's truly a global, declare it in a header as an external, then define it once in a single source module. Include the header in any source module which requires access to the variable.
What's the best way to declare and define global variables
Profile Answers by lakshmi5783 Questions by lakshmi5783
Questions by lakshmi5783