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

(part 12) Han from China answers your C questions

P: n/a
what is the type for this call?

Neo said:
>If i have a :
typedef struct str32{
uint32_t word1;
uint32_t word2;
} word_array;

word_array *my_array;

what would be the data type of this:
myarray->word1
How come it is a uint32_t type and is giving the value of word1? isn't
it still a pointer which is not dereferenced yet?
I was thinking I should have to do *(my_array->word1) to get to
uint32_t type, what goes?
[Please note that there are two (part 11)'s in the "Han from
China answers your C questions" series. Sorry about that. You can
tell I got an F in math at school.]

Neo, buddy, I've decided to give you a little summary for reference
so that you don't have to sift through excess verbiage, cryptic
meanderings, and irrelevant matters of naming to make sense of this
thing. Please forgive any typos on my part.

word_array my_structure;
word_array *my_structure_pointer;
my_structure_pointer = &my_structure;

&my_structure - address of my_structure
my_structure_pointer - address of my_structure
&my_structure_pointer - address of my_structure_pointer

my_structure - refers to my_structure (obviously)
*my_structure_pointer - refers to my_structure

my_structure.word1 - access word1
(*my_structure_pointer).word1 - access word1 (parentheses needed)
my_structure_pointer->word1 - access word1 (shorthand for the previous)

&my_structure.word1 - address of word1
&(*my_structure_pointer).word1 - address of word1
&my_structure_pointer->word1 - address of word1

my_structure_pointer.word1 - DON'T DO THIS
(*my_structure).word1 - DON'T DO THIS
my_structure->word1 - DON'T DO THIS

Yours,
Han from China

Nov 7 '08 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.