Re: A Certain Size/sizeof
From: Gene Wirchenko (gwirchenkoEXCEPT_at_CAPITALSwencomine.com)
Date: 11/15/03
- Next message: Gene Wirchenko: "Re: const Casting"
- Previous message: Ali R.: "Re: const Casting"
- In reply to: Robert W Hand: "Re: A Certain Size/sizeof"
- Next in thread: Ulrich Eckhardt: "Re: A Certain Size/sizeof"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 14 Nov 2003 23:47:32 GMT
On Fri, 14 Nov 2003 18:19:28 -0500, Robert W Hand
<rwhand@NOSPAMoperamail.com> wrote:
[snip]
>count should have the number of rows in the array. Let's take it from
>the beginning. Note that I shall indicate the object array as arr to
>avoid hopeless confusion in the following note.
>
>arr is an array that has 17 columns. The number of rows is determined
>by the initializer. sizeof is an operator that works on the compiler
>side. It determines the size of the object operand in bytes.
>
>So sizeof arr will be the number of bytes that is in arr. Such a size
>will be implementation defined. Note that when the operand of sizeof
>is an array, the array does not decay into a pointer to some type.
>
>arr is an array of an array of 17 ints. When used as the operand of
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>the indirection operator, arr decays into a pointer into an array of
>17 ints. So applying the indirection operator to arr results in an
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>array of 17 ints. When the sizeof operator is then applied, the
^^^^^^^^^^^^^^^^^
>resulting array will not decay further. Rather it will yield the size
>of each row in bytes.
>
>So dividing sizeof arr by sizeof *arr will be the number of rows in
>the object array, arr.
That was a very clear explanation. I could follow it
step-by-step. The above were the missing bits (for me).
Thank you.
><Observation>
>Reading the "arguments" of both sides, I really do not see any reason
>for further anger. It reads like a misunderstanding by both parties.
>Please kiss and make up. ;-)
></Observation>
Sincerely,
Gene Wirchenko
- Next message: Gene Wirchenko: "Re: const Casting"
- Previous message: Ali R.: "Re: const Casting"
- In reply to: Robert W Hand: "Re: A Certain Size/sizeof"
- Next in thread: Ulrich Eckhardt: "Re: A Certain Size/sizeof"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|