Why does a linker error occurs for the segment: main() { extern int i; i=20; printf("%d",sizeof(i)); }

Why does a linker error occurs for the segment: main() { extern int i; i=20; printf("%d",sizeof(i)); }

In the given example extern int i means we only declare the i.It means compiler think that 'i' only used but does not know which memory is allocated to i,and in next line we call the i but because of missing of memory space it gives a linkage error.

By:Vivek Kr. Agarwal
Date:2002-01-09 00:00:00

Post Your Answers


User Email:

User Name:
Answers:

Related C Subjective Links

C Subjective interview questions and answers for experienced and fresher