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

what does this operator do???
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Highly_Amused
Guest







PostPosted: Wed Jun 07, 2006 2:54 am     Reply with quote

I too frequently scan the threads on here, and feel sorry for all the tutors out there that have to teach the un-interested, stoned and in good old english tradition...absolutely paraletic so called students. Put a smile on my face til coffee break! Thanks!
dyeatman



Joined: 06 Sep 2003
Posts: 1934
Location: Norman, OK

View user's profile Send private message

PostPosted: Wed Jun 07, 2006 7:09 am     Reply with quote

Just for the record I have my WELL WORN copy of K&R front and center on the shelf (just in case I lose a few brain cells on occasion I can go back and refresh them) and, early on, read mine cover to cover. They are currently available from Amazon for only $9! I have also subscribed to Dr Dobbs and Circuit Cellar for many years. I get a lot of really neat C programming info, both embedded and PC from those, well worth the money!
deltatech



Joined: 22 Apr 2006
Posts: 87

View user's profile Send private message

PostPosted: Sun Jun 11, 2006 6:53 am     Reply with quote

This is a known as a arrow operator

It is used to access a structur trhough a pointer.

for example

struct
{ int i ;
char ch;

} p,*q;


q points to p

to access indivisual memeber of p , you need to use the arrow pointer as follows

q->i=1; this stament will assign value 1 to the member i.

I hope this helps

Best wishes
deltatech



Joined: 22 Apr 2006
Posts: 87

View user's profile Send private message

PostPosted: Sun Jun 11, 2006 7:00 am     Reply with quote

This is a known as a arrow operator

It is used to access a structur through a pointer.

for example

struct
{ int i ;
char ch;

} p,*q;


q points to p

to access individual memeber of p , you need to use the arrow pointer as follows

q->i=1; this stament will assign value 1 to the member i.

I hope this helps

Best wishes
VanHauser



Joined: 03 Oct 2005
Posts: 88
Location: Ploiesti, Romania

View user's profile Send private message

PostPosted: Sun Jun 11, 2006 12:46 pm     Reply with quote

deltatech, in the code you written, the pointer q doesn't point to anything (or points to some random location in memory), it is just defined as a pointer to that struct. It must be assigned before it is used. To make it point to p, you do it like this:
Code:
q = &p;

After this you can access member data using the arrow operator like you said.

Let's not create more confusion for the "stoners" out there by posting incorrect code samples.
kender



Joined: 09 Aug 2004
Posts: 768
Location: Silicon Valley

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger

PostPosted: Sun Jun 11, 2006 1:16 pm     Reply with quote

VanHauser wrote:
Let's not create more confusion for the "stoners" out there by posting incorrect code samples.


Why not? May be that will make them, finally, read the book. ;)
lewiseley



Joined: 30 Oct 2003
Posts: 24
Location: skegness

View user's profile Send private message Visit poster's website

PostPosted: Tue Jun 13, 2006 11:24 am     Reply with quote

why not torture them first, with pascal.
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Tue Jun 13, 2006 3:29 pm     Reply with quote

OH! OH! I got it! *waves hand madly*

Put them in a round room and tell them to sit in the corner. Twisted Evil
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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