Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: C language declaration "bugs" |
| Date | 2016-10-11 15:03 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <87zimb9e5b.fsf@bsb.me.uk> (permalink) |
| References | <90bf0ba6-5094-4551-8cc0-c60214b14362@googlegroups.com> <87d1j7avp8.fsf@bsb.me.uk> <b4976e0d-cedb-4721-a261-d3597eb43b97@googlegroups.com> |
Thiago Adams <thiago.adams@gmail.com> writes: > On Tuesday, October 11, 2016 at 9:58:52 AM UTC-3, Ben Bacarisse wrote: >> Thiago writes: > >> But now the []s in that position have acquired a new set of meanings: >> >> void f(int n, int a[n]); // variably modified parameter > > > void f(int n, int a[n]); > > This one is a tip? where n is the size? Yes, because the "first level" of []s always just mean "pointer" so the n is really only for documentary purposes. A proper variably modified array parameter would have []s where the size matters: void f(int n, int (*a)[n]); void f(int m, int n, int a[m][n]); Note that the type of a is the same in both of the functions. Here, sizeof a will give the size of a pointer, but sizeof a[0] will depend on n. > I can't find any options to express dynamic arrays in structs. No, you can't, other than the "struct hack" of putting a flexible array member (i.e. an incomplete array declaration) as the last member. <snip> -- Ben.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
C language declaration "bugs" Thiago Adams <thiago.adams@gmail.com> - 2016-10-11 05:17 -0700
Re: C language declaration "bugs" Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-10-11 13:58 +0100
Re: C language declaration "bugs" Thiago Adams <thiago.adams@gmail.com> - 2016-10-11 06:47 -0700
Re: C language declaration "bugs" Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-10-11 15:03 +0100
Re: C language declaration "bugs" Thiago Adams <thiago.adams@gmail.com> - 2016-10-11 07:41 -0700
Re: C language declaration "bugs" BartC <bc@freeuk.com> - 2016-10-11 16:31 +0100
Re: C language declaration "bugs" Keith Thompson <kst-u@mib.org> - 2016-10-11 10:01 -0700
Re: C language declaration "bugs" Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-10-11 19:10 +0100
Re: C language declaration "bugs" BartC <bc@freeuk.com> - 2016-10-11 14:14 +0100
csiph-web