C Programming - Passing a pointer to array
- by Pedro
How do I pass a pointer value to an array of the struct;
For example, on a txt I have this:
John Doe;[email protected];214425532;
My code:
typedef struct Person{
char name[100];
char email[100];
int phone;
}PERSON;
int main(){
PERSON persons[100];
FILE *fp;
char *ap_name;
char *ap_email;
char *ap_phone;
char line[100];
fp=("text.txt","r");
if(fp==NULL){
exit(1);
}
else{
fgets(line,100,fp);
ap_name=strtok(line,";");
ap_email=strtok(NULL,";");
ap_phone=strtok(NULL,";");
}
return 0;
}
My question is how can I pass the value of ap_name, ap_email, ap_phone to the struct?
And, do I need to use all of these pointers?