July 2015
Intermediate to advanced
380 pages
10h 15m
English
In this exercise, you’ll learn how to make a struct, point a pointer at it, and use it to make sense of internal memory structures. We’ll also apply the knowledge of pointers from the last exercise, and then get you constructing these structures from raw memory using malloc.
As usual, here’s the program we’ll talk about, so type it in and make it work.
ex16.c
1 #include <stdio.h> 2 #include <assert.h> 3 #include <stdlib.h> 4 #include <string.h> 5 6 struct Person { 7 char *name; 8 int age; 9 int height; 10 int weight; 11 }; 12 13 struct Person *Person_create(char *name, int age, int height, 14 int weight) 15 { 16 ...