[LC++]Size of structure pointer/array
Carlo Wood
carlo at alinoe.com
Thu Aug 30 11:53:22 UTC 2001
On Wed, Aug 29, 2001 at 09:29:11PM -0400, Paul M Foster wrote:
> Assuming:
>
> //////////////////////
>
> struct int_struct {
> int a;
> int b;
> int c;
> };
>
> void is_func(int_struct *i); // defined elsewhere
>
> int_struct is[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
Use
int_struct is[] = { {1,2,3}, {4,5,6}, {7,8,9} };
>
> is_func(is);
>
> ////////////////////
>
> When I pass "is" to the is_func() function, am I passing the whole array
> of structures, just a pointer to the first element, or what? The size of
Just a pointer.
> "is", when passed to the function (and measured inside the function) is
> the size of a pointer. But I'm concerned that I've passed more than that
> on the stack.
>
> Paul
This is typical C coding however and should not be looked at by those on
this list that want to learn C++ ;) (then you'd use references and
vectors).
--
Carlo Wood <carlo at alinoe.com>
More information about the tuxCPProgramming
mailing list