View Full Version : what does -> mean in C?
nite owl
November 8th, 2007, 06:14 AM
Hi just looking through some tutorials and came across this symbol:
->
just wondering what it means, thanks.
yabbadabbadont
November 8th, 2007, 06:19 AM
It is used when you have a pointer to a structure and you want to dereference one of the stuct's fields.
typedef struct
{
char a;
int b;
} mystruct;
mystruct example;
mystruct *ptr;
ptr = &example;
ptr->a = 'A';
ptr->b = 1;
(*ptr).a = 'B';
(*ptr).b = 2;
hod139
November 8th, 2007, 03:12 PM
In case it isn't clear from yabbadabbadont's post, the
"->" syntax is syntactic sugar for "(*ptr)." .
ptr->
(*ptr).
are equivalent, where the former was introduced strictly for convenience.
Powered by vBulletin® Version 4.2.2 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.