Computer Systems: A Programmer's Perspective (3rd Edition)
Computer Systems: A Programmer's Perspective (3rd Edition)
3rd Edition
ISBN: 9780134092669
Author: Bryant, Randal E. Bryant, David R. O'Hallaron, David R., Randal E.; O'Hallaron, Bryant/O'hallaron
Publisher: PEARSON
Expert Solution & Answer
Book Icon
Chapter 10, Problem 10.10HW

Explanation of Solution

Modified code from figure 10.5:

The modified code for “cpfile.c” is shown below:

//Include header file

#include <stdio.h>

#include "csapp.h"

//Main function

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

{

  //Declare "int" variable

  int n;

  //Create the object for read buffer of type

  rio_t rio;

  //Declare "MAXLINE" for memory

  char buf[MAXLINE];

/* Check the command line arguments. If the command line contains two argument, then copy the infile to standard output */

  if (argc == 2)

  {

    /* Store the descriptor number in "fd" */

    int fd = Open(argv[1], O_RDONLY, 0);

    while ((n = Rio_readn(fd, buf, MAXBUF)) != 0)

      Rio_writen(STDOUT_FILENO, buf, n);

    //Exit the process

    exit(0);

  }

/* Otherwise copy a text file from standard input to...

Blurred answer
Students have asked these similar questions
a. Use an interactive Python session (shell/IDLE) to print out a line of 11 stars 7 times (so there will be 7 lines of output with each line containing 11 stars). b. Write a function that does the same thing as above, having each line printed individually. c. Write a function that uses a loop to do the same thing.
Write a Python program in a Linux/UNIX script called myprogram.py. Write a Python program that continuously (i.e., in an infinite loop) asks the user for a number m. At each iteration of the loop, check in parallel whether m is greater than 10, greater than 20, and greater than 30. Make sure that the three comparisons may be performed in parallel (i.e., so that the three outputs can theoretically be printed in any order). Use the smallest number of processes. Make sure you don’t create zombie processes. Use the code below as a template. Use this template: from os import wait,waitpid,fork # write your code here while (True): #make sure to indent this and the next lines m=float(input('Give me a number: ')) # your code here
Hi, how can i find out what the programm in phyton does without actually using phyton idle for it? :) For example, in the task i was given i had to find out what the programm i sent in the picture prints without inserting the programm into phyton idle.
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr