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 CCS Technical Support

how to access structures

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



Joined: 24 Feb 2016
Posts: 1

View user's profile Send private message

how to access structures
PostPosted: Wed Feb 24, 2016 3:19 am     Reply with quote

hi everyone
I am using ccs compiler version 4.124
I was seeing the example file rtctimer.c
In this example file structures are used.and to access elements of those structures "->" symbol is used like
Code:

unixTime += timeT->tm_sec;


we can also use it as this way
Code:

unixTime += timeT.tm_sec;


what is the difference between both?
From where i can read and study about supported syntax in ccs?
Ttelmah



Joined: 11 Mar 2010
Posts: 19546

View user's profile Send private message

PostPosted: Wed Feb 24, 2016 3:51 am     Reply with quote

Read a C textbook!...

-> is used as a shorthand when dealing with a pointer to a structure.

If 'p' is a pointer to a structure, then p->member accesses the member in the structure being pointed to.

The -> is used inside a function, where timeT has been passed as a pointer.
It's a shorthand for (*timeT).member
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