Hope this helps...
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int main(void)
{
int fd;
char line[101] = {0};
ssize_t readVal;
int ret;
/* open the file in question */
fd = open("tmpp", O_RDONLY);
if ( fd < 0 )
exit(EXIT_FAILURE);
/* read the first 100bytes (0-99)*/
readVal = read(fd, line, 100);
printf("Retrieved first %zu bytes:\n %s\n\n", readVal, line);
/* read the next 100bytes (100-199)*/
readVal = read(fd, line, 100);
printf("Retrieved second %zu bytes:\n %s\n\n", readVal, line);
/* jump to location 300, i.e. skip over 100 bytes */
ret = lseek(fd, 300, SEEK_SET);
if ( ret < 0 ) {
close( fd );
return -1;
}
/* read next 100bytes (300-399) */
readVal = read(fd, line, 100);
printf("Retrieved third %zu bytes - at location 300:\n %s\n\n", readVal, line);
/* close the file descriptor */
close(fd);
exit(EXIT_SUCCESS);
}
obviously, the input can be read not as strings...