By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,797 Members | 1,794 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,797 IT Pros & Developers. It's quick & easy.

Pointer Interpretation

P: 1
I am a C newbie. While trying to reverse engineer a program, I got the following code:

*lastBank++ = (*(((const real_T**)ssGetInputPortSignalPtrs(S, 0))[0]));

Can somebody tell me what it means in plain English. Especially the double pointer
const real_T**.

Thanks

Umesh
Feb 22 '07 #1
Share this Question
Share on Google+
3 Replies


10K+
P: 13,264
I am a C newbie. While trying to reverse engineer a program, I got the following code:

*lastBank++ = (*(((const real_T**)ssGetInputPortSignalPtrs(S, 0))[0]));

Can somebody tell me what it means in plain English. Especially the double pointer
const real_T**.

Thanks

Umesh
Have you read a tutorial on pointers? What do you think it means?
Feb 22 '07 #2

DeMan
100+
P: 1,806
Hiya,

Pointers are one of the most confusing aspects of c for people new to the idea.
I think the biggest mistake most people make when they first encounter pointers is that they assume * (asterisk) means pointer. Get that idea out of your head. Think of * as "The value at" and make a habit of declaring pointers by prefixing the asterisk, and postfixing something that makes you think 'pointer'.
eg:
UINT8 *my_ptr

Then you can translate this as "I want the value at my_ptr to be an unsigned int". Furthermore, when you refer to my_ptr, you are referring to the pointer, and any time you want to talk about the value you need to say *my_ptr (the value AT my pointer).
The biggest trouble most people I know encountered (and certainly the biggest problem I had) in coming to understand pointers) was that when you think of the asterisk declaring the pointer, you start to think that things starting with the asterisk must be pointers.
In actual fact, once declared, the variable ITSELF is the pointer, and once you introduce the asterisk you are looking for the value at that memory address. (and for something that I thought would be easy to explain, I'm starting to confuse myself).

In short, try to remember that * means value at (we won't get into the ampersand &).

In plain English, then:

*lastBank++ = (*(((const real_T**)ssGetInputPortSignalPtrs(S, 0))[0]));

could tranlate (roughly) to:

set the value one past lastBank to be the value you get (when you think of it as a pointer to a pointer to an unchangeable structure called real_T)if you take the value 0 positions past the result given to you by the method ssGetInputPortSignalPtrs when given inputs S and 0.
Feb 22 '07 #3

10K+
P: 13,264
Hiya,

Pointers are one of the most confusing aspects of c for people new to the idea.
I think the biggest mistake most people make when they first encounter pointers is that they assume * (asterisk) means pointer. Get that idea out of your head. Think of * as "The value at" and make a habit of declaring pointers by prefixing the asterisk, and postfixing something that makes you think 'pointer'.
eg:
UINT8 *my_ptr

Then you can translate this as "I want the value at my_ptr to be an unsigned int". Furthermore, when you refer to my_ptr, you are referring to the pointer, and any time you want to talk about the value you need to say *my_ptr (the value AT my pointer).
The biggest trouble most people I know encountered (and certainly the biggest problem I had) in coming to understand pointers) was that when you think of the asterisk declaring the pointer, you start to think that things starting with the asterisk must be pointers.
In actual fact, once declared, the variable ITSELF is the pointer, and once you introduce the asterisk you are looking for the value at that memory address. (and for something that I thought would be easy to explain, I'm starting to confuse myself).

In short, try to remember that * means value at (we won't get into the ampersand &).

In plain English, then:

*lastBank++ = (*(((const real_T**)ssGetInputPortSignalPtrs(S, 0))[0]));

could tranlate (roughly) to:

set the value one past lastBank to be the value you get (when you think of it as a pointer to a pointer to an unchangeable structure called real_T)if you take the value 0 positions past the result given to you by the method ssGetInputPortSignalPtrs when given inputs S and 0.
Spoilsport .
Feb 22 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.