I'm trying to printf specific lines of a .txt file by comparing the first char of the line to "-", and only printing if it isn't the same.
void menu() {
FILE *fp =fopen("save_projeto.txt","r");
char line[MAX_LENGTH];
fgets(line, MAX_LENGTH, fp);
while(!feof(fp)){
if (strcmp(line[0], "-") == 0) {
fgets(line, MAX_LENGTH, fp);
}
else {
printf("%s", line);
fgets(line, MAX_LENGTH, fp);
}
}
}
The file I'm trying to print is formatted like this, with 20 Locals and each one with up to 1.3 different PDI's.
1º Local
Amsterdao
1.1 PDI
Casa de Anne Frank
-Descricao: Museu biografico localizado na cidade de Amsterdao, capital dos Paises Baixos.
-Horario de funcionamento: *7*19
When I build the code, it runs without error messages, but the console does not print anything at all.