fgets()是否移动文件指针? [英] Does fgets() move the file pointer ?

查看:135
本文介绍了fgets()是否移动文件指针?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

fgets()函数是否将文件指针自动移动到该位置,直到我提到的大小参数?例如:

b
$ b

文件p.txt的内容是我是个好孩子。在使用fgets(a,5,fp1)
之后,文件指针前进5个位置?


在任何书中都找不到这个。因此查询。在使用fgets(a,5,fp1)之后,文件指针在前面移动了5个位置。

解决方案


指针 fp1 不受 fgets 调用(或任何其他的 stdio I / O例程);指向 fp1 指针的 FILE 对象将被更新以反映新的文件位置,但指针本身不会改变。

Does the fgets() function move the file pointer automatically to the position till the parameter of the size mentioned by me ?

for example :

the content of the file p.txt is " I am a good boy " . After using fgets(a,5,fp1) does the file pointer move 5 positions ahead ?

Could not find this clearly in any book . Hence the query .

解决方案

after using fgets(a,5,fp1) does the file pointer move 5 positions ahead ?

The pointer fp1 is not affected by the fgets call (or any other stdio I/O routine); The FILE object that fp1 points to will be updated to reflect the new file position, but the pointer itself does not change.

这篇关于fgets()是否移动文件指针?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆