Ya i know... I have to answer some of these questions for the folks
at a very crude level!!
   My perspective is just to give a visual help in understanding structures
and the reason we use them, at a very basic level. Of course the example
I gave wont work on all systems, for eg: it will break on 64bit systems
having
LP64 data model where the compiler may optimize and pad bytes along with
the integer field mentioned in the structure to make it dword aligned.
  Anyways, it is just for beginners to get a brief understanding of it.
Apologies
for others who are bugged by the crude level of my solution!!

Regards,
Santosh.

--

Santosh Vernekar
Sr. Dev. Engineer
Calsoft PVT. LTD.

  # Linux: Because rebooting is only for adding new hardware.
  # Failure is not an option -- it comes bundled with Windows.




On 12/28/06, Paul Herring <[EMAIL PROTECTED]> wrote:

  On 12/28/06, Santosh Vernekar <[EMAIL PROTECTED]> wrote:
>
>
>     You might want to try understanding how to access different fields
> of a structure.
> Every structure can be visualized like a block of memory and accessing
> fields is like
> accessing  the block at different offsets depending on the sizes of the
> fields.
>     Hence ..
> typedef  struct {                    *char  **ch;
>                    *int*  id;
>                    *float*  salary;
>   } Base;
>
> Base orgin;
>
>
> origin + 0 (Start Address)  point to the first element (char *ch)
> origin + (sizeof char *)   points to the second element in the block
> (int id)
>

Not necessarily, and unless you specify certain options in the compiler,
not ususally.

--
PJH

#713059 +(1255)- [X]

<SaintAlvus> Does the name Doctor Pavlov ring a bell?




--
Santosh Vernekar
Sr. Dev. Engineer
Calsoft PVT. LTD.

  # Linux: Because rebooting is only for adding new hardware.
  # Failure is not an option -- it comes bundled with Windows.

Reply via email to