-3

If I have struct for instance:

struct head {
   int s; 
   char x;
};

And I have pointer pointing to this struct, how can I access char x using this pointer?

user3047661
  • 119
  • 2
  • 8
  • With the `->` operator, usually... I suggest you double check your tutorial/book instead of expecting SO to provide one spontaneously. – StoryTeller - Unslander Monica Apr 24 '17 at 09:20
  • [Here's a complete list of operators](https://www.csee.umbc.edu/courses/104/fall06/burt/precedenceTable.html). Read on the `->` operator. – Cong Ma Apr 24 '17 at 09:21
  • Arrow syntax. ```myStructPtr->myMember```. In future, maybe google or a book would be a good idea. You'll probably find a more comprehensive answer – Luke K Apr 24 '17 at 09:22

1 Answers1

3

Supposing that you have :

struct head headNode;
struct *head headPtr = &headNode;

you can access char x with :

headPtr->x;
Marievi
  • 4,951
  • 1
  • 16
  • 33