- Feb 28, 2008
- 1,262
- 0
- 71
I need to read in 9 and just 9 bytes at a time from a very large file and increment the file position to read in the next 9 bytes after I have done calculations on the first 9
If my calculations don't use up the entire 9 then keep the leftover in the buffer and read in more subtracted by whatever is in buffer like say I read in 9 but only the first 5 match my calculations then I would have four left over and I want them to go to the front of the buffer and read in five bytes to the end of the buffer so that buffer is always exactly nine bytes the leftovers at the beginning and the read in bytes appended to the leftovers.
How would I be able to do this?
This is some of the code I found on google with a few modifications:
I am a beginner.
Thank you
If my calculations don't use up the entire 9 then keep the leftover in the buffer and read in more subtracted by whatever is in buffer like say I read in 9 but only the first 5 match my calculations then I would have four left over and I want them to go to the front of the buffer and read in five bytes to the end of the buffer so that buffer is always exactly nine bytes the leftovers at the beginning and the read in bytes appended to the leftovers.
How would I be able to do this?
This is some of the code I found on google with a few modifications:
Code:
unsigned long long int fd;
char buffer[9] = {0};
char * myfifo = "/tmp/myfifo";
mkfifo(myfifo, 0666);/*what does this mean?\*
printf("What would you like to send?\n");
fgets(buffer, 9, stdin);
if((fd = open(myfifo, O_WRONLY)) < 0) what does O_WRONGLY mean and how do I get it to compile my compiler says error O_WRONGLY undeclared
printf("Couldn't open the FIFO for writing!\n");
else {
write(fd, buffer, strlen(buffer));
close(fd);
Thank you
Last edited: