当它们之间有字符串时如何从文件中读取多个整数

问题描述

我正在尝试使用循环从文件中读取多个整数。我面临的问题是这些整数之间有一个字符串。我的目标是找到文件中的最后一个整数 例如:- 123 hello 1253 world 所以在上面的例子中,最后一个整数是 1253。

int id;
p=fopen("o.txt","r");
while(!feof(p))
{
    fscanf(p,"%d",&id);
    fseek(p,13,SEEK_CUR);
} ```

   

I used `fseek()` to jump over the string. There were 13 characters from the last digit to the beginning of the next digit.
This does not work and I ended up in an infinite loop.
Can anyone help?
Thank you

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)