335 views
1 votes
1 votes

i am unable to understand how this extern int data type actually works here

please help me to understand it??

1 Answer

Best answer
1 votes
1 votes
defining "extern" is like giving a promise to the compiler that let me use it here as this variable is defined somewhere else and when you will use it you will get the memory reference.

So using extern is only declaring that this variable is available somewhere.

In this question we declared the variable $i$ but it was not intialized anywhere it does not have any memory allocated to it.

So in the next line when the program executes $i=1024$ then it will get no memory reference to $i$ and will throw undefined reference $'i'$
selected by

Related questions