I have an array defined in a file and in another I have to use it, for e.g-
/* a.c - defines an array */
int a[] = {1,2,3,4,5,6,7,8,9};
/* b.c - declare and use it. */
#define COUNT ((sizeof a)/(sizeof int))
extern int a[]; //size of array
.
.
.
int i;
for(i=0; i<COUNT; i++)
printf("%d", a[i]);
.
.
.
Now when I try to compile it it gave me error saying that sizeof cann't be used on incomplete type.
Can anybody tell me how to handle such case in C/C++? I don't want to array subscript in a.c
Thanks in advance
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…