Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extern using pointer instead of array

Tags:

c

extern

Suppose we have 2 files

1) file1.c

int Appples[10];

2) file2.c

extern int *Appples;

Is there any prob with this type of declaration except that i will have to handle size independently ?

like image 265
MAG Avatar asked Jun 20 '26 10:06

MAG


1 Answers

This is covered in C FAQs 6.1

The type pointer-to-type-T is not the same as array-of-type-T. Use extern char a[].

while this answer addresses the issue more specifically. The final point is: an array isn't a pointer and you shouldn't treat one as such.

like image 118
Marco A. Avatar answered Jun 21 '26 22:06

Marco A.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!