+ 1

Do you know the difference between global and external variable scope?

Example for explaining why they are what they are, would greatly help.

2nd Aug 2018, 6:22 AM
Avik Arefin
Avik Arefin - avatar
3 Answers
+ 3
avik arefin local variable are available within function scope: for example, in fun1() { int a; } Here, int a is local to function and is accessible within function , not outside the function. Now coming to global variable... if you declare variable outside main i.e. globally, it becomes accessible in the entire code.. extern variable are important when you have more header files.. suppose you declare variable in one class header and get those variables assigned in other class, it is useful.. https://stackoverflow.com/questions/2652545/extern-and-global-in-c
5th Aug 2018, 6:58 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
+ 2
Happy learning...
7th Aug 2018, 7:52 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
+ 1
Ketan Lalcheta Thanks for the link.
7th Aug 2018, 7:50 AM
Avik Arefin
Avik Arefin - avatar