How to access **pointer from structure

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • eeshani
    New Member
    • Aug 2008
    • 2

    #1

    How to access **pointer from structure

    Hi,

    I want to access ** pointer from pointer to structure. Pls guide me in the code given below:

    sturct m
    {
    int i;
    struct n ** pCurrLine; // Ram pointer
    struct m *prev;
    struct m *nxt;

    };

    struct n
    {
    int x[10];
    struct n *pre;
    struct n *nxt;
    };


    *pcurrline = &pLine_cur_p tr;
    struct n *pLine_cur_ptr;
    pLine_cur_ptr = &cur_Line;

    struct m *mCurr;

    Now if I have to access pCurrLine then how should I proceed.

    I tried :

    mCurr->pCurrLine = mCurr->pCurrLine->pre ; // error

    mCurr = mCurr->pre; /// Is right


    pls help

    Thanks,
  • newb16
    Contributor
    • Jul 2008
    • 687

    #2
    Originally posted by eeshani
    *pcurrline = &pLine_cur_p tr;
    if pcurrline is not initialized ( points nowhere ) you will write
    this pointer somewhere in ram. It is not good.

    I tried :

    mCurr->pCurrLine = mCurr->pCurrLine->pre ; // error
    mCurr->pCurrLine is a pointer to pointer, so you need something like
    (*(mCurr->pCurrLine))->pre

    Comment

    • eeshani
      New Member
      • Aug 2008
      • 2

      #3
      Originally posted by newb16
      if pcurrline is not initialized ( points nowhere ) you will write
      this pointer somewhere in ram. It is not good.


      mCurr->pCurrLine is a pointer to pointer, so you need something like
      (*(mCurr->pCurrLine))->pre


      Thank you...I worked according to your suggestion. I am also type casting the ROm pointer into RAM so its working at this stage...lets see
      Once again Thanks...I appreciate your help.

      Comment

      Working...