I have an xml like file and I have to read only a part of the file.(subfile). Then I have to search this subfile for some "strings".
I thought of reading a file from a start pointer till an end pointer(which would be the subfile). Then I should work with th开发者_开发知识库is subfile and inspect line by line of the subfile using fgets().
The trouble is, fgets seems to take only a file pointer as parameter :( Any ideas??
You can use mmap()
on UNIX/Linux to map a file to memory. This should make it easier to isolate a part of the file and work with it. Your xml library will probably want a buffer if it parses raw data, so you can just pass it the mmap result.
Here is an excellent example of usage
http://www.cs.purdue.edu/homes/fahmy/cs503/mmap.txt
精彩评论