Skip to content

Instantly share code, notes, and snippets.

@StevenJL
Created May 24, 2017 08:07
Show Gist options
  • Save StevenJL/e154594b02e4927667cc6037b50f990e to your computer and use it in GitHub Desktop.
Save StevenJL/e154594b02e4927667cc6037b50f990e to your computer and use it in GitHub Desktop.
c_notes/pointers_to_structs
struct date
{
int day;
int month;
int year;
}
struct date my_bday;
struct date *bday_pointer;
// pointer references struct
bday_pointer = &my_bday;
// accessing a struct member through a pointer has a short-hand
// the two lines below are equivalent
(*bday_pointer).day
bday_pointer->day
// setting members of the struct through the pointer:
bday_pointer->day = 2;
bday_pointer->month = 12;
bday_pointer->year = 1982;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment