0
I am trying to read a CSV file that has different lines. I am using fgets and Strtok to store in a list. the problem is that being different lines do not know how to stop and move to the next.
typedef struct{
int id_viagem;
int duracao;
int mes_init;
int dia_init;
int ano_init;
int hora_init;
int min_init;
int id_estacao_init;
int mes_final;
int dia_final;
int ano_final;
int min_final;
int id_estacao_final;
char *bicicleta;
int tipo;
int nascimento;
char *genero;
}INFO_VIAGEM;
This is the structure that gives rise to the list, and these are the different line types:
41,460,7/28/2011 12:10:00,22,7/28/2011 12:18:00,49,B00353,Registered,1972,Male
61,1315,7/28/2011 12:33:00,36,7/28/2011 12:55:00,38,B00228,Casual,,
auxx=strtok(NULL, str_div);
tipo=auxx;
if(strcmp(tipo, "Casual") == 0){
z.tipo=0;
}
else{
z.tipo=1;
auxx=strtok(NULL, str_div);
z.nascimento=atoi(auxx);
auxx=strtok(NULL, str_div3);
z.genero=auxx;
}
Just like the first line and always Registered it always reads even what there is. How can I do?
Edit and ask the question in Portuguese or use stackoverflow in English.
– Lucas Trigueiro
thanks, had not realized the difference of the site. This already edited.
– Jorge Proença