Zdravím,
poradil by mi někdo, jak vytvořit funkci ADD, aby zařadila hodnoty o1,o2,o3 z main(), tak aby vzniklo pole s[0] Alice..., s[1] Pavel..., s[2] Aleš...? Díky
#include <stdio.h>
#include <string.h>
typedef struct
{
char* name ;
char* surname;
char* address;
char* day;
char* month;
int year;
char* telnumber;
char* email;
int* count;
} human;
void create_list(human s[])
{
human people[3];
for (int i = 0; i < 3; i++)
{
people[i].name = "0";
people[i].surname = "0";
people[i].address = "0";
people[i].day = "0";
people[i].month = "0";
people[i].year = 0;
people[i].telnumber = "0";
people[i].email = "0";
}
}
void add(human s[], human o)
{
}
void print(human s[])
{
for (int i = 0; i<3;i++)
{
printf("Seznam osob: %s %s, %s, tel: %s, email: %s, %s.%s.%d \n", s[i].name, s[i].surname, s[i].address, s[i].telnumber, s[i].email, s[i].day, s[i].month, s[i].year);
}
}
human create_human(char name[], char surname[], char address[], char *day, char *month, int year, char telnumber[], char email[])
{
human human;
human.name = name;
human.surname = surname;
human.address = address;
human.day = day;
human.month = month;
human.year = year;
human.telnumber = telnumber;
human.email = email;
return human;
}
main()
{
human list_human[100], o1, o2, o3, o;
int count = 0;
o1 = create_human("Alice", "Pokorna", "Holicka 62", "2", "1", 1992, "214 145 478", "alice.pokorna@email.cz");
o2 = create_human("Pavel", "Novak", "tr. 17 listopadu 24", "13", "1", 1992, "654 784 478", "pavel.novak@seznam.cz");
o3 = create_human("Ales", "Maly", "Holicka 62","6","5", 1989, "772 847 457", "ales.maly@upol.cz");
add(list_human,o1);
add(list_human,o2);
add(list_human,o3);
print(list_human);