I'm having trouble with a piece of coding I'm working on. It involves linked lists and certain annoying pointers. Here is some sample code:
PersonType *person;
FILE *c;
c = fopen("file.csv", "r");
char in[100];
fgets(in, 80, c); //Edited
root->head->next = 0;
char *getNum = strtok(in, ";");
char *getName = strtok(NULL, ";");
char *getHome = strtok(NULL, ";");
strcpy(root->head->getNum, getNum);
strcpy(root->head->getName, getName);
strcpy(root->head->getHome, getHome);
person = root->head;
if(person != 0){
while(person->next != 0){
person=person->next;
}
}
//DEGUG
printf("Successfully Made a Person NODE");
The code won't read from the file and I am completely stumped why. In the XCODE debugger/tracer it initializes all the get chars with nil. Can someone please point me in the right direction?
Thanks.
EXAMPLE FILE
P1;Elyza;45 Random RD
P2;Ian;78 Shark CL