I'm trying to separate a string read from a file by the token '#'. StrTok separates the first token correctly but when i print what is supposed to be the second token it returns nothing but (null).
I tried to change the format of the file that is being read and using an aux variable to hold the content of strtok(NULL,"#"), but the results dont change.
void ler_fich_cidades(Lista_Cidades cidade,Lista_Pontos pt){
FILE *p;
int file_check=0;
char linha[TAM];
Lista_Pontos ptos;
Cada_cidade city;
char *aux = (char*)malloc(TAM*sizeof(char));
p = fopen("locais.txt", "r");
while(!feof(p)){
fgetstr(linha,sizeof(linha),p); //this function removes any '\n'.It is working,because it is used for other things
strcpy(cidade->nome_cidade,strtok(linha,"#")); //This line is working as intended
printf("%s\n",cidade->nome_cidade);
strcpy(ptos->ponto.nome,strtok(NULL,"#")); //This one is not
printf("%s\n",ptos->ponto.nome); //Printing (null)
}
}
The file being read has the following format:
"#Coimbra"
"#Universidade De Coimbra#E uma das universidades mais antigas do mundo ainda em operaçao, sendo a mais antiga e uma das maiores do pais.#8:00h-18:00h#Segunda,Terca,Quarta,Quinta,Sexta,Sábado"
The output is supposed to be: Coimbra Universidade De Coimbra
But the actual output is just: Coimbra