Anonymous user
Read a file line by line: Difference between revisions
→{{header|C}}: syntax hilight
(→{{header|C}}: mmap method) |
(→{{header|C}}: syntax hilight) |
||
Line 273:
Implementation using mmap syscall. Works on Linux 2.6.*, should work on *BSDs (they invented mmap, after all). Line reading routine takes a callback function, each line is passed into callback as begin and end pointer. Let OS handle your memory pages, we don't need no stinking mallocs.
<lang C>#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
Line 351:
int main()
{
return read_lines("
}
</lang>
|