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.
相关问题
- Multiple sockets for clients to connect to
- What is the best way to do a search in a large fil
- React Native Inline style for multiple Text in sin
- glDrawElements only draws half a quad
- Index of single bit in long integer (in C) [duplic
What you need is the strstr function written for file handles. This is a generic implementation of strstr. You can pretty easily modify it to use file buffers instead of another string, so I won't do your work for you :P
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.