here is my piece of code
#include<stdio.h>
main ()
{
extern int i;
i=20;
printf("%d",i);
}
When I compile it I get error
ka2.c: In function ‘main’:
ka2.c:6: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘long unsigned int’
/tmp/ccGXrSE5.o: In function `main':
**ka2.c:(.text+0x6): undefined reference to `i'**
collect2: ld returned 1 exit status
I want to know the reason of error in lines which I have bolded.
You have declared
ibut haven’t defined it, that’s why the linker is complaining.