Re: [C] Array bounds in function prototypes
From: Jason Spashett (not-for-mail_at_b.com)
Date: 03/10/04
- Next message: Conditional Zenith: "boolean variables & protected variables"
- Previous message: Ward: "Q about statement in Shtern's Core C++ A Software Engineering Approach"
- In reply to: Mike Wahler: "Re: [C] Array bounds in function prototypes"
- Next in thread: Greg Comeau: "Re: [C] Array bounds in function prototypes"
- Reply: Greg Comeau: "Re: [C] Array bounds in function prototypes"
- Reply: Andrey Tarasevich: "Re: [C] Array bounds in function prototypes"
- Reply: Richard Heathfield: "Re: [C] Array bounds in function prototypes"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 10 Mar 2004 20:11:47 -0000
"Mike Wahler" <mkwahler@mkwahler.net> wrote in message
news:4kK3c.13371$%06.1728@newsread2.news.pas.earthlink.net...
...
> Well, just like it says, an array argument 'decays' into a pointer
...
Thanks for the detailed information. However, exactly why does it decay to a
pointer in a function prototype? I can't see why the array typing
information could not be preserved, is it for backwards compatibility? [ And
as an aside: is this the same in C++, I would presume not ]
I realised that I could pass a pointer to an array of n elements to do the
job, I've never actually passed fixed sized array before. I normally just
say char *map instead.
In the case of printf("%u", sizeof x); won't x get promoted to unsigned int
anyway, even if one does cast a size_t type to some unsigned type it may not
work anyway (in theory) ?
- Next message: Conditional Zenith: "boolean variables & protected variables"
- Previous message: Ward: "Q about statement in Shtern's Core C++ A Software Engineering Approach"
- In reply to: Mike Wahler: "Re: [C] Array bounds in function prototypes"
- Next in thread: Greg Comeau: "Re: [C] Array bounds in function prototypes"
- Reply: Greg Comeau: "Re: [C] Array bounds in function prototypes"
- Reply: Andrey Tarasevich: "Re: [C] Array bounds in function prototypes"
- Reply: Richard Heathfield: "Re: [C] Array bounds in function prototypes"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|