Sometimes we might need to declare global variable. Let say I have 5 files (cat.c, dog.c, tiger.c, rabbit.c and animal.c). I declare a global integer variable “debug†at animal.c
int debug;
In order to let other modules from other file besides animal.c to gain the global access, I need to add a line for ( cat.c, dog.c, tiger.c and rabbit.c).
extern int debug;
I use debug global variable to store the value of debug mode. With different debug mode, I can control what to print on screen to ease the debugging.
give me some examples on extern variables