c - Is there any significant difference between `->` and `.` for accessing struct members? -
For people familiar with C and its nuances it can be very too , I do not I am familiar with either and can not tell that Like I have Does this make a difference beyond the different syntax, do I Tried searching Google / SO, but I did not tell anything which was a favorite, if any, method. Both look correct, but I can not help but one of the more specific uses ( It depends on how the structure is declared if we have the actual straight variable , Then use -> or . There is a important difference in reaching a member of a strat using . struct my_struct :
struct my_struct {int x; Int y; }; Struct my_struct grid; via struct my_struct grid member of x Access the grid .x or grid-> x ? And if someone makes a difference, who can I like? - & gt; ) is the case. . If we have an indicator for a structure, then use -> :
struct my_struct * s = ...; S- & gt; X = 5; Printf ("% d \ n", s-> x); Struct my_struct s2 = ...; S2.x = 4; Printf ("% d \ n", s2.x);
Comments
Post a Comment