Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ Moderated > Re: Array of un...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 2 Topic 9822 of 9909
Post > Topic >>

Re: Array of unknown bound

by Jiang <goo.mail01@[EMAIL PROTECTED] > Jul 24, 2008 at 02:37 AM

>
> What I understand is that the following code is ill-formed
>
> char buf[2][10];
> void fn(char p[][], int size){}
> int main(){
>         fn(buf, 2);
>
> }
>
> However what I understand from the Footnote is that the following
> should be well-formed as part of the exclusion
>
> char buf[2][10];
> void fn(char (*p)[][], int rows, int cols){}  // p is a pointer to an
> array of unknown bounds
> int main(){
>         fn(&buf, 10, 2);
>
> }
>
> However this also gives compilation error. Is my understanding of the
> footnote wrong or is my code above wrong?

The above two examples are both ill-formed, since we have a simpler
rule in 8.3.4/p3, which says:

     When several “array of” specifications are adjacent,
     a multidimensional array is created; the constant expressions
     that specify the bounds of the arrays can be omitted only for
     the first member of the sequence.

Therefore, both "char p[][]" and "char (*p)[][]" are ill-formed.

Please note that array and adjacent "array-of"s  are quite different,
usages apply to normal array does not apply to high order
array-of's at all.

HTH

Jiang


-- 
      [ See http://www.gotw.ca/resources/clcm.htm
for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]
 




 2 Posts in Topic:
Array of unknown bound
rkldabs@[EMAIL PROTECTED]  2008-07-23 19:23:50 
Re: Array of unknown bound
Jiang <goo.mail01@[EMA  2008-07-24 02:37:24 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Aug 20 13:15:21 CDT 2008.