A certain file foo contains the ASCII text string This file contains 28 bytes.. That is,...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
A certain file foo contains the ASCII text string "This file contains 28 bytes.". That is, the bytes of the file, viewed as 8-bit integers, contain the values 0x54, 0x65, 0x73, 0x74, and 0x20, etc. a. Suppose a program opens foo for reading and writing (file descriptor fd is returned), and then does the following. Assume buf is a 30-byte array of char. if ((rv = read (fd, buf, 10)) < 0) {...handle error... } if ((rv = write(fd, buf, 10)) < 0) {... handle error... } Assuming both calls return 10, what does the file contain after this code runs? b. Suppose the same program next calls 1seek (fd, 0, SEEK_SET) to "rewind" the file offset to the beginning, and then does the following: if ((rv = read (fd, buf, 30)) < 0) {...handle error... } strcpy (buf, "That"); if ((rv = write(fd, buf, rv)) < 0) {... handle error... } What does the file now contain? A certain file foo contains the ASCII text string "This file contains 28 bytes.". That is, the bytes of the file, viewed as 8-bit integers, contain the values 0x54, 0x65, 0x73, 0x74, and 0x20, etc. a. Suppose a program opens foo for reading and writing (file descriptor fd is returned), and then does the following. Assume buf is a 30-byte array of char. if ((rv = read (fd, buf, 10)) < 0) {...handle error... } if ((rv = write(fd, buf, 10)) < 0) {... handle error... } Assuming both calls return 10, what does the file contain after this code runs? b. Suppose the same program next calls 1seek (fd, 0, SEEK_SET) to "rewind" the file offset to the beginning, and then does the following: if ((rv = read (fd, buf, 30)) < 0) {...handle error... } strcpy (buf, "That"); if ((rv = write(fd, buf, rv)) < 0) {... handle error... } What does the file now contain?
Expert Answer:
Answer rating: 100% (QA)
a Suppose a program opens foo for reading and writing file descriptor fd is returned and then does t... View the full answer
Related Book For
Java An Introduction To Problem Solving And Programming
ISBN: 9780134462035
8th Edition
Authors: Walter Savitch
Posted Date:
Students also viewed these programming questions
-
Why have you chosen this nursing Field of Specialization or Major? What influenced you in selecting your intended major of study and what goal(s) have you set for the future?
-
You just received a $8.800 bonus and have decided to save the money to use in retirement 47 years from now. How much money will the bonus be worth in retirement if you can earn an average of 5.6...
-
This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of an array of objects as a class data...
-
What type of isomers are exhibited by [Fe(en) 3 ]Cl 2 (en = ethane-1,2-diamine)? no isomers are possible. cis and trans isomers fac and mer isomers optical isomers
-
1. Given her current situation, list some suggestions on what Shelby should do with a tax refund of $800. 2. Based on her current and future life situation, what tax planning strategies should she...
-
The Income Statement section of the worksheet of Smith Company for the year ended December 31, has $179,000 recorded in the Debit column and $203,344 in the Credit column on the line for the Income...
-
Internal ecological accounting provides information for a number of internal environmental impact added objects. What are these objects? Does internal ecological accounting information differ...
-
The controller of Arrowroot Company wishes to improve the companys control system by preparing a monthly cash budget. The following information relates to the month ending July 31, 20X1: June 30,...
-
A long-established caf located in inner west Brisbane residential suburb is facingit'stime to figure out their budget for the coming quarter. During the last quarter, the caf had spent roughly $500...
-
Pharr Foods Company produces a variety of food products including a line of candies. One of its most popular candy items is Far Stars, a bag of a dozen, individually wrapped, star-shaped candies made...
-
Trump Ltd. decided to increase its bill payment time from 20 days to 40 days. It was said that they wanted to exercise some cost control and optimize cash flow. i) What impact will this have on...
-
Rewrite the following equations into standard form and graph using the x- and y-intercepts of the line with the given equation. Check your graph with the original problem in slope-intercept form to...
-
Jerry, who lives in Kingston, had a ten seater dining table that he decided to sell as he was moving to a smaller house. On Monday February 27, Jerry telephoned his friend Ken who lived in St Ann...
-
How does the process of socialization shape individual identity in diverse societies, and what impact does this have on broader patterns of social cohesion or division?
-
You are considering a risky investment that you expect will either be worth 245,000 in 1 year, or 130,000, with probabilities of 0.75 and 0.25 for each outcome, respectively. You could invest in...
-
Prepare a statement of cash flows (using the indirect method) for the Midland Manufacturing Corporation for the year ending December 2016, based on the following comparative balance sheets. Midland...
-
Solve the following. Table 9.2 Average Returns for Bonds 1950 to 1959 1960 to 1969 1970 to 1979 1980 to 1989 1990 to 1999 2000 to 2009 1950 to 1959 1960 to 1969 1970 to 1979 1980 to 1989 1990 to 1999...
-
QUESTION 2 The CEO of Farisha Hijab Sdn Bhd insisted on further investigation to be carried out that he also required Mr Muaz to conduct the analysis of variance for the material and labour of the...
-
Write a program similar to the one in Listing 10.10 that can write an arbitrary number of Species objects to a binary file. (Species appears in Listing 5.19 of Chapter 5.) Read the file name and the...
-
Imagine a program that compresses files by 80 percent and stores them on storage media. Before the compressed file is stored, it must be divided into blocks of 512 bytes each. Develop an algorithm...
-
What would the following statements, when used in a Java program, display on the screen? int age; age = 20; System.out.println ("My age is"); System.out.println(age);
-
Name four disruptive business models and describe what they offer to their customers.
-
How is IT contributing to the success of the on-demand and shared economies?
-
What are the key strategic and tactical questions that determine an organizations profitability and management performance?
Study smarter with the SolutionInn App