OK so I have a struct:
I have used fgets to get a line that looks like '1500 ALAN 7'Code:struct person{ int arrivaltime; char name[NAME_LEN]; int num_items; };
Then I used strtok with space as delimiter. I originally had the name as char* name. The strtok worked with that but I was having a problem that when I went back to view values of previous people i would get either the most recent persons name entered or nothing.
(i.e. If i input 1500 ALAN 7 then 2000 BOB 15 and tried to print alan's info id get
1500 BOB 7
So I'm pretty sure doing char name[] will fix that but I cant get this line working:
It's throwing an incompatible types in assignment. How to I fix it to put the strtok as the correct type?Code:people[j].name = strtok(NULL, " ");