无法使用fscanf

时间:2018-10-09 17:01:22

标签: c

while循环不起作用,我不明白为什么。它不会给我任何错误,但不会读取任何输入内容。 该文件的内容为:

4
$11$ pelle 
$2$ pollo 
$333$ palla 
$41$ alla

我的代码:

int main()
{
    int v[30],s,i;
    FILE *f;

    f=fopen("dizionario.txt","r");
    if (f==NULL) {
        printf("Error.\n");
        return -1;
    }

    fscanf(f,"%d",&s);
    i=0;
    while (fscanf(f,"$%d$",&v[i])==1) {
        i++;
    }

    for (i=0;i<s;i++) {
        printf("%d\n",v[i]);
    }


    return 0;
}

1 个答案:

答案 0 :(得分:0)

framework: #default_locale: '%locale%' default_locale: 'en' translator: paths: - '%kernel.project_dir%/translations' fallbacks: - 'en' 可用于读取文件中的每一行。然后使用@Route("/", name="home") 从行中获取值。

fgets
相关问题