Im trying to read a file a then insert it in a linked list but i'm having trouble to use sscanf. I dont know why but it never goes through the first if with sscanf.The file is a result from the user input and some users have more information than others so i need to differentiate the way a read each line.
The file is exactly like this.
201263066#1,2,3#9#1,2,3,4,5,6,7,8,10,11,
201263065#0,0,0#0#
201263064#0,0,0#0#
201363524#4,5,7#2#2,3,4
201596874#1,9,8#8#2,8,9,6,5,2,1
typedef struct user{
  int id;
  int city[3];
  int *places;
  int hot;
}User;
typedef struct Users_node *List_users;
typedef struct Users_node{
  User user;
  List_users next;
}Each_user;
void read_file(List_users u){
  FILE *p;
  int i=0,a,n=0;
  char line[1024];
  List_users aux2;
  char city_ids[20];
  char *pt,*pt2;
  int hotspot;
  int user_id;
  char places_id[200];
  p = fopen("userPref.txt", "r");
  while(!feof(p)){
      fgets(line,sizeof(line),p);
      if(sscanf(line,"%d#%s#%d#%s",&user_id,city_ids,&hotspot,places_id) == 4){
          aux2->user.id  = user_id;
          pt = strtok(city_ids,",");
          while(pt != NULL) {
              a = atoi(pt);
              printf("%d\n", a);
              aux2->user.city[n++] = a;
              pt = strtok(NULL, ",");
          }
          aux->user.hot = hotspot;
          pt2 = strtok(places_id,",");
          while(pt2 != NULL) {
              a = atoi(pt);
              printf("%d\n", a);
              aux2->user.places[n++] = a;
              pt2 = strtok(NULL, ",");
          }
      }else{
          aux2->user.id = atoi(strtok(line,"#"));
          aux2->user.city[0] = atoi(strtok(NULL,","));
          aux2->user.city[1] = atoi(strtok(NULL,","));
          aux2->user.city[2] = atoi(strtok(NULL,","));
          aux->user.hot = atoi(strtok(NULL,"#"));
      }
  }
  fclose(p);
}
 
    