Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* 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]);
- .
- .
- .
- int a[] = {1, 2, 3};
- const int lengthofa = sizeof( a ) / sizeof( a[0] );
- extern int a[];
- // the extern (thanks Tim Post) declaration means the actual storage is in another
- // module and fixed up at link time. The const (thanks Jens Gustedt) prevents it
- // from being modified at runtime (and thus rendering it incorrect).
- extern const int lengthofa;
- void somefunc() {
- int i;
- for ( i = 0; i < lengthofa; i++ )
- printf( "%dn", a[i] );
- }
- extern int a[9];
- #ifndef A_DEF
- #define A_DEF
- int a[] = {1,2,3,4,5,6,7,8,9};
- #endif
Add Comment
Please, Sign In to add comment