简体   繁体   English

C ++使用fgets读取另一行

[英]C++ read another line with fgets

I am coding in c++ for the nintendo ds and must use the "FILE" type to access a text file. 我正在用C ++编写Nintendo ds的代码,并且必须使用“ FILE”类型来访问文本文件。 So I'm using fgets to view the contents of the text file but I don't see any way to view the contents of anything but the first line, looking in the documentation . 因此,我正在使用fgets来查看文本文件的内容,但是除了在文档中查找第一行以外,我看不到任何其他方式来查看内容。

Is there another command that would do such a thing or is there a way to make fgets read a different line? 是否有另一个命令可以执行此操作,或者是否有办法使fget读取另一行?

Fgets will read from the FILE position where you are at. Fget将从您所在的FILE位置读取。 And when you use it, it reads a line and the position is now on the next line. 当您使用它时,它会读取一行并且位置现在在下一行。 So if you keep on calling it, it will give you all the lines. 因此,如果您继续调用它,它将为您提供所有帮助。 When EOF is reached it will return the line up to that point, and subsequent calls will return NULL. 到达EOF时,它将返回到该点的线路,随后的调用将返回NULL。

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

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