I'm having trouble with strcmp(). I've read a topic on it, but couldn't understand.
I'm using strcmp to compare a variable (that comes from fgets-sscanf pair) with the string "DATA" and others.
I declared the variable as char, and already tried to put a limit on the number of characters of the variable both on strcmp and on the declaration of the variable, but it still doesn't work.
Could you give me some help?
Here is the code segment:
Code:
void leitura(char linha[200], info informacao){
char verifica;
/*Usa-se if e [strcmp] para verificar sscanfs*/
sscanf(linha,"%s",&verifica);
if(strcmp(verifica[4],"DATA")==0){
sscanf(linha,"DATA %d %d %d\n",&informacao.dia,&informacao.mes,&informacao.ano);
informacao.aviso=1;
}
if(strcmp(verifica[4],"AREA")==0){
sscanf(linha,"AREA %d %d %d %d\n",&informacao.x1,&informacao.y1,&informacao.x2,&informacao.y2);
informacao.aviso=2;
}
if(strcmp(verifica[9],"INDIVIDUO")==0){
sscanf(linha,"INDIVIDUO %d %d %d %d\n",&informacao.especie,&informacao.individuo,&informacao.x_individuo,&informacao.y_individuo);
informacao.aviso=3;
}
if(strcmp(verifica[7],"COLONIA")==0){
sscanf(linha,"COLONIA %d %d %d %d %d\n",&informacao.especie_col,&informacao.colonia,&informacao.tamanho,&informacao.x_colonia,&informacao.y_colonia);
informacao.aviso=4;
}
}