473,396 Members | 1,608 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

The "->" operator

What does this do? I've been looking online and I've seen mention that it exists
as well as examples to it's use but still no explination as to exactly what it does.

TFTH,
Jeff
Nov 14 '05 #1
7 23175
Jeff Rodriguez wrote:

What does this do? I've been looking online and I've seen mention that it exists
as well as examples to it's use but still no explination as to exactly what it does.

TFTH,
Jeff


It's a struct dereference by pointer.

struct V a;
struct V *b;

b = &a;

a.<something> and b-><something> are now exactly the same thing.

--
Les Cargill
Nov 14 '05 #2
Les Cargill wrote:
Jeff Rodriguez wrote:
What does this do? I've been looking online and I've seen mention that it exists
as well as examples to it's use but still no explination as to exactly what it does.

TFTH,
Jeff

It's a struct dereference by pointer.

struct V a;
struct V *b;

b = &a;

a.<something> and b-><something> are now exactly the same thing.

--
Les Cargill

Easy enough!

Thank you much.

Jeff
Nov 14 '05 #3
Jeff Rodriguez <ne********@gurugeek.EXAMPLENOSPAM.com> writes:
What does this do? I've been looking online and I've seen mention that
it exists as well as examples to it's use but still no explination as
to exactly what it does.


The -> operator dereferences its left operand, then accesses one
of the members of the referenced object (which must be of
structure or union type). a->b is equivalent to (*a).b. The ->
operator is simply there to reduce the need for parentheses in
accessing a structure member through a pointer.
--
Here's a tip: null pointers don't have to be *dull* pointers!
Nov 14 '05 #4
Jeff Rodriguez wrote:
What does this do? I've been looking online and I've seen mention that
it exists as well as examples to it's use but still no explination as to
exactly what it does.


The -> operator is a structure element pointer dereference operator. It
takes a pointer to a structure on the left and a membername on the right,
and results in the value of the member of the structure as pointed to by the
pointer.

In other words, assuming something defined like

struct { int number } *pointer;

then

pointer->number

is a shortform for

(*pointer).number

That's it.

--
Lew Pitcher, IT Consultant, Application Architecture
Enterprise Technology Solutions, TD Bank Financial Group

(Opinions expressed here are my own, not my employer's)

Nov 14 '05 #5
In <ilcCb.2069$J77.331@fed1read07> Jeff Rodriguez <ne********@gurugeek.EXAMPLENOSPAM.com> writes:
What does this do? I've been looking online and I've seen mention that it exists
as well as examples to it's use but still no explination as to exactly what it does.


What does your favourite C book say about it?

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #6
Dan Pop wrote:
In <ilcCb.2069$J77.331@fed1read07> Jeff Rodriguez <ne********@gurugeek.EXAMPLENOSPAM.com> writes:

What does this do? I've been looking online and I've seen mention that it exists
as well as examples to it's use but still no explination as to exactly what it does.

What does your favourite C book say about it?

Dan


Dan, it wasn't necessary to lapse into sarcasm. Why not just follow the
example of the prior respondents and answer the question in a serious
and congenial manner (or refrain from making any reply if the question
has already been answered)? Expertise does not excuse bad manners.

Nov 14 '05 #7
"I.M.A Troll" <tr***@email.con> wrote in message news:<3F************@email.con>...
Dan Pop wrote:
In <ilcCb.2069$J77.331@fed1read07> Jeff Rodriguez <ne********@gurugeek.EXAMPLENOSPAM.com> writes:

What does this do? I've been looking online and I've seen mention that it exists
as well as examples to it's use but still no explination as to exactly what it does.

What does your favourite C book say about it?

Dan


Dan, it wasn't necessary to lapse into sarcasm. Why not just follow the
example of the prior respondents and answer the question in a serious
and congenial manner (or refrain from making any reply if the question
has already been answered)? Expertise does not excuse bad manners.


This could be a sign I've been hanging around c.l.c. too long, but
Dan's answer is perfectly appropriate (if a bit brusque, but that's
part of Dan's charm). Answers to basic questions such as this are
best found in your handy C reference manual, not in an online
newsgroup where there is some delay in getting an answer, and where at
least one of the answers you get will be wrong or useless.

The OP needs to get into the habit of checking his C reference manual
*first*; if he has additional questions, he needs to check out the
FAQ; and then, if he still needs guidance, ask a question here.
Nov 14 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

43
by: steve | last post by:
I am quite frustrated with php’s include, as I have spent a ton of time on it already... anyone can tell me why it was designed like this (or something I don’t get)? The path in include is...
2
by: steve | last post by:
Hi, I need to do conditional script "include", but like to pull the code from db instead of a file. How do I do that? Reason: I like to implement some complex regex logic, and make it table...
15
by: Bobby C. Jones | last post by:
Is there an advantage to either of these methods, or is it simply a matter of style? I used to use the "as" method, but later gave it up for the "is" method as the intent of the code seems a...
43
by: markryde | last post by:
Hello, I saw in some open source projects a use of "!!" in "C" code; for example: in some header file #define event_pending(v) \ (!!(v)->vcpu_info->evtchn_upcall_pending & \...
8
by: Ulysse | last post by:
Hello, I need to clean the string like this : string = """ bonne mentalit&eacute; mec!:) \n <br>bon pour info moi je suis un serial posteur arceleur dictateur ^^* \n ...
2
by: Angus | last post by:
I am trying to change the selection in Javascript - but this HTML element is not a standard option control. On the web page it looks like a dropdown list - and you click on the right hand down...
5
by: Maria Sudderman | last post by:
I have a prblem with the "onClick" command. onClick="insert('<a href="URI">', '</a>')"> but this is not correct! why? Maria
1
by: manchin2 | last post by:
Hi, Can anybody please provide the information about "&quot" and its use, if possible please provide an example. ...
2
by: jmash | last post by:
Suppose I have the following string whch is part of an xml string: String s= "Script Id=&quot;Test&quot; " And I need to get s= "Script Id="Test" " Can anyone tell me how this can acheived? ...
3
by: tvnaidu | last post by:
I compiled tinyxml files (.cpp files) and when I am linking to create final exe in Linux, I am getting lot of errors saying "undefiend reference" to "operator new" and "delete", any idea?. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.