I want to fill typedef
struct by function. I tried:
typedef struct{
char *first_name, *last_name;
int id;
Date birthday;
} Person;
void ReadPerson(Person* person){
person = (Person*)malloc(sizeof(Person));
person->first_name = readString();
person->last_name = readString();
scanf("%d",&(person->id));
ReadDate(&(person->birthday));
}
the main function:
void main(){
Person *tmp = NULL;
ReadPerson(tmp);
}
After calling ReadPerson
tmp
with Bad Ptr value.