Skip to content

Instantly share code, notes, and snippets.

@david-bergstrom
Created April 13, 2015 07:14
Show Gist options
  • Save david-bergstrom/d0f4485d6c26e33a3134 to your computer and use it in GitHub Desktop.
Save david-bergstrom/d0f4485d6c26e33a3134 to your computer and use it in GitHub Desktop.
A small example of pointers of pointers in comparison pointers of instances.
struct Wheel {
int number;
};
struct Car {
struct Wheel* wheel_pointer;
struct Wheel wheel_instance;
};
int main() {
struct Car car;
struct Wheel wheel;
struct Car* c_pointer = &car;
car.wheel_pointer = &wheel;
c_pointer->wheel_pointer->number = 4;
c_pointer->wheel_instance.number = 2;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment