我有一个问题,我还没有找到有效的解决方案。这真的很容易,但我不明白该怎么做。
我有一个包含一些行的文件,例如:
#comment
#comment
icecream 5
pizza 10
pie 7
#comment
tortillas 5
fajitas 5
我希望我的程序只读取不以#
.
FILE *pf;
char first [20], second [20];
pf = fopen("config.conf", "r");
if (pf)
{
while (! feof(pf))
{
fscanf(pf, "%s \t ", first);
while(!strcmp(first,"#")){ `HERE I NEED JUMP TO NEXT LINE`
fscanf(pf, "%s \t ", first);
}
fscanf (pf, "%s \t ", second);
printf("Food: %s \t Cost: %s \n", first, second);
}
fclose(pf);
}
else
printf( "Errore nell'aprire config.conf\n");