View previous topic :: View next topic |
Author |
Message |
Highly_Amused Guest
|
|
Posted: Wed Jun 07, 2006 2:54 am |
|
|
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
|
|
Posted: Wed Jun 07, 2006 7:09 am |
|
|
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
|
|
Posted: Sun Jun 11, 2006 6:53 am |
|
|
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
|
|
Posted: Sun Jun 11, 2006 7:00 am |
|
|
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
|
|
Posted: Sun Jun 11, 2006 12:46 pm |
|
|
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:
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
|
|
Posted: Sun Jun 11, 2006 1:16 pm |
|
|
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
|
|
Posted: Tue Jun 13, 2006 11:24 am |
|
|
why not torture them first, with pascal. |
|
|
rnielsen
Joined: 23 Sep 2003 Posts: 852 Location: Utah
|
|
Posted: Tue Jun 13, 2006 3:29 pm |
|
|
OH! OH! I got it! *waves hand madly*
Put them in a round room and tell them to sit in the corner. |
|
|
|