Question: Enter the read-writer pointer values at the time instants in the following program. You may assume it is executed from the beginning to the end.
Enter the read-writer pointer values at the time instants in the following program. You may assume it is executed from the beginning to the end. Assume that the file, file1.txt, exists and is empty. Enter the Read-Write Pointer (or, file pointer) values at time instants (a) through (f) into the Blackboard Final Exam Submission.
char * buf1[7];
buf1[0] = T;
buf1[1] = H;
buf1[2] = O;
buf1[3] = U;
buf1[4] = G;
buf1[5] = H;
buf1[6] = T;
char *buf2[7];
int nread, nwrite;
fd = open("file1.txt", O_RDWR);
(a)
nwrite = write(fd, buf1, 4);
(b)
lseek(fd, (offset_t) 2, SEEK_SET);
(c)
nwrite = write(fd, buf1, 5);
(d)
lseek(fd, (offset_t) -4, SEEK_END);
(e)
nread = read(fd, buf2, 4);
(f)
What would be the contents of the file, file1.txt, after the above program in problem 3 is completed. Enter a sequence of characters (case sensitive) into Blackboard Final Exam Submission.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
