如何读取C中某个位置的文本文件? [英] How to read a text file upto certain position in C?

查看:136
本文介绍了如何读取C中某个位置的文本文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将一个字符串作为参数传递给我的程序并在文本文件中提取它的位置。
我们可以在C ??中读取一个文本文件到达这个特定位置吗?如果是,那么请告诉我如何。

I am passing a string as an argument to my program and extracting its position in a text file. Can we read a text file only upto this certain position in C?? If yes, then please tell me how.

推荐答案

只需使用fread()最多可达到的字节数文件中的位置。例如,如果您知道要读取1928字节的位置,只需用fread读取那么多字节。

Just use fread() up to the number of bytes that puts you to that "position" in the file. For example, if you know you want to read up to the position at 1928 bytes, just read that many bytes in with fread.

这篇关于如何读取C中某个位置的文本文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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