#include #include #include // data structure typedef struct _Person { char name[25]; int age; } Person; /** * create new structure of type Person */ Person *Person_create() { Person *p = (Person *) malloc(sizeof(Person)); return p; } /** * remove existing Person */ void Person_destroy(Person *p) { free(p); } /** * initialize data structure * @param p pointer to Person * @param n name of the Person * @param a age of the Person */ void Person_init(Person *p, char *n, int a) { strcpy(p->name, n); p->age = a; } /** * set name of given Person * @param p pointer to Person * @param n name of the Person */ void Person_set_name(Person *p, char *n) { strcpy(p->name, n); } /** * display name of the Person * @param p pointer to Person */ void Person_print(Person *p) { printf("%s %d", p->name, p->age); } // main int main() { Person *p = Person_create(); Person_init(p, "toto", 10); Person_print(p); Person_destroy(p); return 0; }