Function pread for windows

The pread function is used to read N bytes from a stream/file from a given offset point. It is natively present on linux/unix but not on windows. However its easy to implement it on windows using the lseek and read functions. Here is an example

#include <io.h>
#include <stdio.h>

int pread(unsigned int fd, char *buf, size_t count, int offset)
	if (_lseek(fd, offset, SEEK_SET) != offset) {
		return -1;
	return read(fd, buf, count);


Last Updated On : 13th February 2012

Subscribe to get updates delivered to your inbox

About Silver Moon

Php developer, blogger and Linux enthusiast. He can be reached at [email protected]. Or find him on

Leave a comment