简体   繁体   English

用fscanf读取2 int和\\ n-有想法吗?

[英]Read 2 int and \n with fscanf - thoughts?

In my current project for C language, I have to read from a file 2 int and make sure that after those there is a newline. 在我当前的C语言项目中,我必须从文件2 int中读取,并确保在这些文件之后有换行符。 I'm trying to use the fscanf function (fscanf(f,"%d %d",&a,&b)), but this way I don't know if these are in the same line or if there is a newline after. 我正在尝试使用fscanf函数(fscanf(f,“%d%d”,&a,&b)),但是这种方式我不知道它们是否在同一行或后面是否有换行符。

Any thoughts? 有什么想法吗?

使用fgets()将整行读取到缓冲区中,然后检查读取的行,也许使用sscanf()解析出两个整数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM