Question: Next to each marked statement of the program given below, specify the offset on the corre sponding file after the statement is carried out successfully.

 Next to each marked statement of the program given below, specify

Next to each marked statement of the program given below, specify the offset on the corre sponding file after the statement is carried out successfully. void main() \{ char buf [100]; int fd1 = open("file1.txt", O_RDWR | O_CREAT, S_IRUSR I S_IWUSR); int fd2 = open("file2.txt", O_RDWR | O_CREAT, S_IRUSR I S_IWUSR); strcpy(buf, "12345678901234567890"); write(fd2, buf, 20); write(fd1, buf, 15); lseek(fd1, 5, SEEK_SET); read(fd1, buf, 10); lseek(fd2, -5, SEEK_END); lseek(fd1, -5, SEEK_CUR); //be careful here, what does buf contain? write(fd2, buf, strlen(buf)); \} void main(){ char buf [100]; int fd1 = open("file1.txt", O_RDWR | O_CREAT, S_IRUSR | S_IWUSR); int fd2 = open("file2.txt", O_RDWR | O_CREAT, S_IRUSR | S_IWUSR); strcpy(buf, "12345678901234567890"); write(fd2, buf, 20); write(fd1, buf, 15); lseek(fd1, 5, SEEK_SET); read(fd1, buf, 10); lseek(fd2, -5, SEEK_END); lseek(fd1, -5, SEEK_CUR); //be careful here, what does buf contain? write(fd2, buf, strlen(buf)); \}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related General Management Questions!