I have a struct like this
struct Patient {
char* name;
char* address;
char* socialSecurityNumber;
char* typeOfExamination;
bool isExpress;
}
And I have to fill a dynamic array of this struct from a txt file like this: (delimiter: ";")
Andrew;Address street first;123;pulmonary;1
Matthew;Address street second;456;COVID;0
Lisa;Address street third;789;rectum;0
After opening the file and reading the file:
while (fgets(line, 255, (FILE*) fPtr)) {
char *p = strtok (line, ";");
patients[i].name=(char*)malloc(sizeof(char*));
strcpy(patients[i].name, p);
p = strtok (NULL, ";");
patients[i].address=(char*)malloc(sizeof(char*));
strcpy(patients[i].address, p);
...
i++;
}
After the second malloc/strcpy I get a sysmalloc: Assertion failed error
What am I doing wrong?