Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- typedef char NAME[41];
- typedef struct date
- {
- int month;
- int day;
- int year;
- } DATE;
- typedef struct person
- {
- NAME name;
- int age;
- float height;
- DATE bday;
- } PERSON;
- typedef struct list
- {
- void *data;
- struct list *next;
- } LIST;
- int main(void)
- {
- PERSON *person;
- int num;
- puts("Enter the initial number of records:");
- if (scanf("%d", &num) < 1)
- num = DEF_NUM;
- while (num-- > 0)
- {
- person = (PERSON *) malloc(sizeof(PERSON));
- inputPersonalData(person);
- addPersonalDataToDatabase(person);
- }
- void inputPersonalData(PERSON *person)
- {
- printf("enter the name");
- scanf("%s", person->name);
- printf("enter the age");
- scanf("%d", &person->age);
- printf("enter the height");
- scanf("%f", &person->height);
- printf("enter the birthdate");
- scanf("%d/%d/%d", &person->bday.month, &person->bday.day, &person->bday.year);
- printf("%s %d %f %d %d %d", person->name, person->age, person->height, person->bday.month,
- person->bday.day, person->bday.year);
- // head->data = &person->name;
- // printf("%p", head->data);
- }
- void addPersonalDataToDatabase(PERSON *person)
- {
- // add(head, tail, person);
- // need help here once I call the function add it always leaves
- // with exit code 11
- }
- void add(LIST **head, LIST **tail, void *data)
- {
- if (*tail == NULL)
- {
- *head = *tail = (LIST *) malloc(sizeof(LIST));
- (*head)->data = data;
- (*head)->next = NULL;
- } else
- {
- (*tail)->next = (LIST *) malloc(sizeof(LIST));
- *tail = (*tail)->next;
- (*tail)->data = data;
- (*tail)->next = NULL;
- }
- }
Add Comment
Please, Sign In to add comment