Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

101 Database Exercises Text Workbook

Authors: McGraw-Hill

2nd Edition

0028007484, 978-0028007489

More Books

Students also viewed these Databases questions

Question

Explain the purpose of a business plan.

Answered: 1 week ago