Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

extern multidimensional arrays question

Status
Not open for further replies.

svar

Programmer
Aug 12, 2001
349
GR
A question on the right way to use extern with multidim arrays
#define dim1 10
#define dim2 10
int a[dim1][dim2];
main(){
int foo();
extern int a[][];
}

foo(){
extern int a[][];
...
}

compiles fine, but in foo, a[][] is undefined
-unless I am missing something


while if in the main and foo I say
extern int a[dim1][];
I get a compilation error
invalid use of array with unspecified bounds


 
You just can't leave the dimensions empty
[tt]extern int a[dim1][dim2];[/tt]

Though you might be able to leave the FIRST dimension empty, like you can with an array parameter to a function.
[tt]extern int a[][dim2];[/tt]


--
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top