|
|
View previous topic :: View next topic |
Author |
Message |
hadeelqasaimeh
Joined: 05 Jan 2006 Posts: 105
|
Previous identifier must be a pointer |
Posted: Tue Aug 01, 2006 12:58 am |
|
|
hi all..
i cant understand what this error indicate!!!
Code: | Previous identifier must be a pointer
A -> may only be used after a pointer to a structure. It cannot be used on a structure itself or other kind of variable.
|
help ,,...please |
|
|
Ttelmah Guest
|
|
Posted: Tue Aug 01, 2006 4:21 am |
|
|
What it says.....
If you have a structure:
Code: |
structure demo_struct {
int8 val1;
int16 val2;
} fred;
|
Then you can access the elements in 'fred', with:
fred.val1
and
fred.val2
However if you take the _address_ of this structure, you can use this with:
Code: |
struct demo_struct * pointer_to_fred;
pointer_to_fred=fred;
|
Then:
pointer_to_fred->val1
and
pointer_to_fred->val2
Will access the same elements. The '->' construct, accesses the element in the structure _addressed_ by the value in from of the construct.
However:
fred->val1
or
fred->val2
Will give the error message you are getting. This is because 'fred', when used to access a value, is the structure, not the address of the structure (though C allows the name on it's own to be used to represent the address, as is ued to put the address into 'pointer_to_structure'...).
You are using the '->' construct with an element in front, that is not the address of (pointer to) a 'structure' (or union).
Best Wishes |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|