CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Previous identifier must be a pointer

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
hadeelqasaimeh



Joined: 05 Jan 2006
Posts: 105

View user's profile Send private message

Previous identifier must be a pointer
PostPosted: Tue Aug 01, 2006 12:58 am     Reply with quote

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 Embarassed
Ttelmah
Guest







PostPosted: Tue Aug 01, 2006 4:21 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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