From: harley_chan@hotmail.com (Tylenol)
Subject: Re: how to determine the size of dynamic array??
Date: 7 Aug 2003 13:56:02 -0700 [thread overview]
Message-ID: <becbc481.0308071256.2534600a@posting.google.com> (raw)
In-Reply-To: 6_sYa.1689$K_4.849@news.cpqcorp.net
Thanks Ed Vogel,
For dynamic array, the block of memory is allocated by "malloc()" such
as
int *a = malloc(16);
When I use sizeof(a), it gives me 8 not 4. Anything wrong?? or I use
the "sizeof()" function in wrong way.
some correction in the previous message: the "mallocate()" should be
"mallocblksize():
Thanks
Harley
"Ed Vogel" <edward.vogel_nospam@hp.com> wrote in message news:<6_sYa.1689$K_4.849@news.cpqcorp.net>...
> If by "dynamic array" you mean what the C Standard calls
> "variable length array", the C compiler on Tru64 has this
> support, and you just use the sizeof() operator to get the
> size of the array. For example:
>
> int x = 5;
> main() {
> int a[x]; /* Declare a varible length array */
> printf("size is %d\n",sizeof(a));
> }
>
> will emit: "size is 20" when run.
>
> Ed Vogel
> HP C Engineering
>
> "Tylenol" <harley_chan@hotmail.com> wrote in message
> news:becbc481.0308061530.22556518@posting.google.com...
> | Hi All:
> | Does anyone have ideas how to determine the size of dynamic array? I
> | know MSVC have a function called "_msize()" which doing this kind of
> | job. However, I am not sure on Unix Tru64 have a similar function or
> | not. The most similar function I found is "mallocate()" but this
> | function returns the array size is always larger than original
> | requested size of array. Any function in Unix Tru64 doing the same job
> | as "_msize()"? Please Help!!!
> |
> | Thanks in advance
> | Harley
next prev parent reply other threads:[~2003-08-07 20:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-08-06 23:30 how to determine the size of dynamic array?? Tylenol
2003-08-07 14:02 ` Ed Vogel
2003-08-07 20:56 ` Tylenol [this message]
2003-08-08 14:00 ` Ed Vogel
2003-08-20 17:59 ` Jerry Feldman
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox