incrementing the address ofn initialised structure - Embedded

This is a discussion on incrementing the address ofn initialised structure - Embedded ; hi, i am trying to increment the address of an initialised structure.but it is always showing/printing the same address even after incrementing the address. code part: struct codestruct { init i; int j}; struct codestruct initstruct = {1,2}; struct ptrstruct ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: incrementing the address ofn initialised structure

  1. incrementing the address ofn initialised structure

    hi,
    i am trying to increment the address of an initialised structure.but it
    is always showing/printing the same address even after incrementing the
    address.

    code part:
    struct codestruct { init i; int j};
    struct codestruct initstruct = {1,2};
    struct ptrstruct = &initstruct;
    for(INT I+):I<3;i++)
    printf("\n ptrstruct = %d \n",ptrstruct);
    ptrstruct++;
    }


  2. Re: incrementing the address ofn initialised structure

    Try:

    struct codestruct { init i; int j};
    struct codestruct initstruct = {1,2};
    struct codestruct *ptrstruct = &initstruct; /* CHANGED */
    for(I=0:I<3;I++)
    {
    printf("\n ptrstruct = %d \n",ptrstruct);
    ptrstruct++;
    }

    --


    Regards,


    Graham Baxter
    Freelance Software Engineer (VxWorks, Linux and pSOS BSPs)
    Graham Baxter (Software) Limited
    http://www.gbsw.co.uk
    fromnewsgrp@NOSPAMgbsw.co.uk

    "Ramakrishnaprasad.A" wrote in message
    news:1143109928.987068.312780@i40g2000cwc.googlegr oups.com...
    > hi,
    > i am trying to increment the address of an initialised structure.but it
    > is always showing/printing the same address even after incrementing the
    > address.
    >
    > code part:
    > struct codestruct { init i; int j};
    > struct codestruct initstruct = {1,2};
    > struct ptrstruct = &initstruct;
    > for(INT I+):I<3;i++)
    > printf("\n ptrstruct = %d \n",ptrstruct);
    > ptrstruct++;
    > }
    >




+ Reply to Thread