sign in | join about | help | sitemap
Connecting Tech Pros Worldwide
eeshani's Avatar

How to access **pointer from structure


Question posted by: eeshani (Newbie) on August 21st, 2008 05:45 PM
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_ptr;
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,
2 Answers Posted
newb16's Avatar
newb16 August 21st, 2008 05:52 PM
Familiar Sight - 145 Posts
#2: Re: How to access **pointer from structure

Quote:
Originally Posted by eeshani
*pcurrline = &pLine_cur_ptr;

if pcurrline is not initialized ( points nowhere ) you will write
this pointer somewhere in ram. It is not good.

Quote:
Originally Posted by
I tried :

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

mCurr->pCurrLine is a pointer to pointer, so you need something like
(*(mCurr->pCurrLine))->pre
eeshani's Avatar
eeshani August 21st, 2008 09:10 PM
Newbie - 2 Posts
#3: Re: How to access **pointer from structure

Quote:
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.
Reply
Not the answer you were looking for? Post your question . . .
197,047 members ready to help you find a solution.
Join Bytes.com

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 197,047 network members.
Post your question now . . .
It's fast and it's free

Popular Articles

Top C / C++ Contributors