www.delorie.com/archives/browse.cgi | search |
X-Authentication-Warning: | delorie.com: mail set sender to djgpp-bounces using -f |
From: | Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de> |
Newsgroups: | comp.os.msdos.djgpp |
Subject: | Re: array size inside of a function |
Date: | 4 Mar 2004 13:57:20 GMT |
Organization: | Aachen University of Technology (RWTH) |
Lines: | 29 |
Message-ID: | <c27ck0$g7b$1@nets3.rz.RWTH-Aachen.DE> |
References: | <baec0bf0 DOT 0403022220 DOT 3534cf24 AT posting DOT google DOT com> <c2489p$oce$1 AT news DOT rz DOT uni-karlsruhe DOT de> <baec0bf0 DOT 0403032116 DOT 3d91c482 AT posting DOT google DOT com> |
NNTP-Posting-Host: | ac3b07.physik.rwth-aachen.de |
X-Trace: | nets3.rz.RWTH-Aachen.DE 1078408640 16619 137.226.33.205 (4 Mar 2004 13:57:20 GMT) |
X-Complaints-To: | abuse AT rwth-aachen DOT de |
NNTP-Posting-Date: | 4 Mar 2004 13:57:20 GMT |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Reply-To: | djgpp AT delorie DOT com |
Andrey <huli_ebtyt AT list DOT ru> wrote: > > sizeof(char **) == address size = 4 on 32bit machines. > > > so in main(), array name is not a pointer? Right. It will "decay" into a pointer if you use it as one, but it "is" not a pointer. This is a very common misunderstanding among new C programmers, and unfortunately one that is being stated as fact by many careless C book authors. Passing an array as an argument to some function is one of the usages that counts as "using it as a pointer". The only cases that don't count as such, actually, are use of the 'sizeof' or '&' operators on the name of the array. > and there no way free from passing size? Essentially: no. It's thus usually a good plan to join the pointer and the length into a struct: typedef struct array_of_foo { foo *pointer; size_t length; } array_of_foo; -- Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de) Even if all the snow were burnt, ashes would remain.
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |