Пример #1
0
int main(int argc, char *argv[]) {

    // make two people structures
    struct person *vic = personCreate(
                        "Vicfred", 23, 173, 80);
    struct person *ana = personCreate(
                        "Anabel", 23, 160, 65);

    // print'em out and where they're in memory
    printf("Vic is at memory location %p:\n", vic);
    personPrint(vic);
    printf("Bethabel is at memory location %p:\n", ana);
    personPrint(ana);

    // make everyone age 20 years old and print'em again
    vic->age += 20;
    vic->height += 5;
    vic->weight -= 5;
    personPrint(vic);

    ana->age += 20;
    ana->weight += 5;
    personPrint(ana);

    // destroy'em both so we clean up
    personDestroy(vic);
    personDestroy(ana);

    return 0;
}
static Person personCopy(Person person) {
	assert(person);
	return personCreate(person->name, person->id);
}