Function pread for windows

By | February 13, 2012

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

Related Post

Leave a Reply

Your email address will not be published. Required fields are marked *