Created
May 24, 2017 08:07
-
-
Save StevenJL/e154594b02e4927667cc6037b50f990e to your computer and use it in GitHub Desktop.
c_notes/pointers_to_structs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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