dereferencing a pointer to a complex structure? [message #43417] |
Mon, 11 April 2005 08:14  |
zuzucat@gmail.com
Messages: 4 Registered: April 2005
|
Junior Member |
|
|
I have a troulbe dereferencing a pointer to a complex structure.
multidata = replicate({ grds:ptr_new(findgen(nx, ny))}, n_level)
data = replicate({time:0, level:multidata}, obs)
I
DL> print, (*data[3].level[3].grds)[0,4]
4.00000
ptr_data = ptr_new(data)
I tried (*(*data[3].level[3].grds))[0,4], but it doesn't work.
Any help would be appreciated.
best,
Nobuki Matsui
CDC/NOAA
|
|
|
Re: dereferencing a pointer to a complex structure? [message #43481 is a reply to message #43417] |
Tue, 12 April 2005 15:48  |
JD Smith
Messages: 850 Registered: December 1999
|
Senior Member |
|
|
On Tue, 12 Apr 2005 12:57:46 -0700, zuzucat@gmail.com wrote:
> Mr. Chris Torrence at RSI kindly phoned my supervisor to tell us the
> answer.
>
> Thank you very much, all.
>
> print, (*(*ptr_data)[3].level[3].grds)[0,4]
> best,
This is exactly how the tutorial tells you to do it (even though this
isn't the question you had asked).
The easy to remember, basic rule from the tutorial: group with (*xxx)
all "xxx" which are pointers, unless the () would then occur on the
"outside" of the expression (it wouldn't hurt, it's just a waste).
So in your case the pointer "ptr_data" must be treated this way:
(*ptr_data)
as must the pointer "(*ptr_data)[3].level[3].grds":
(*(*ptr_data)[3].level[3].grds)[0,4]
if you didn't want to subscript the final FINDGEN, you could just use:
*(*ptr_data)[3].level[3].grds
JD
|
|
|
|
|
|
Re: dereferencing a pointer to a complex structure? [message #43488 is a reply to message #43417] |
Tue, 12 April 2005 12:30  |
Benjamin Hornberger
Messages: 258 Registered: March 2004
|
Senior Member |
|
|
David Fanning wrote:
> David Fanning writes:
>
>
>> Yeah, never could I. :-(
>
>
> Say, what!? I'm getting ready to return to Germany for another
> couple of months. This must be what happens when the ol' German
> language CDs get the dust brushed off them. :-(
Oh, I can't wait to read more about your adventures!
Benjamin
|
|
|
|
|