#include #include #include struct Station { int id; char *name; }; static void destroy_station(struct Station *station) { if (station != NULL) { free(station->name); free(station); } } int main(void) { struct Station *station = malloc(sizeof *station); if (station == NULL) { return 1; } station->name = NULL; station->id = 4; station->name = malloc(6); if (station->name == NULL) { destroy_station(station); return 1; } memcpy(station->name, "Ridge", 6); printf("%d: %s\n", station->id, station->name); destroy_station(station); return 0; }