Question: What would the following program print out, assuming that the file specified by fname contained abcde (without the quotes). You must explain your answer! Answers

What would the following program print out, assuming that the file specified by fname contained abcde (without the quotes). You must explain your answer! Answers with no explanation receive no credit. #include "csapp.h"

int main(int argc, char *argv[])

{

int fd1, fd2, fd3;

char c1, c2, c3;

char *fname = argv[1];

fd1 = Open(fname, O_RDONLY, 0);

fd2 = Open(fname, O_RDONLY, 0);

fd3 = Open(fname, O_RDONLY, 0);

Dup2(fd2, fd3);

Read(fd1, &c1, 1);

Read(fd2, &c2, 1);

Read(fd3, &c3, 1);

printf("c1 = %c, c2 = %c, c3 = %c ", c1, c2, c3);

return 0;

}

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 Databases Questions!