d. [6] Assume that a file test.file exists and the file has only one word Hello...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
d. [6] Assume that a file "test.file" exists and the file has only one word "Hello" in its first line. What is the message do you seen after running the following C program: #include <stdio.h> #include <string.h> #include <sys/types.h> #include <fcntl.h> int main(int argc, char *argv[]) { pid t chpid; int fd, variable, status; char ch; variable = 9; fd = open("test.file", O_RDONLY); chpid = fork(); if (choid != 0) { } else { /* Executed only by the child */ variable = 42; } wait(&status); } close(fd); printf("The child has changed the variable to: %d\n", variable); printf("The child has also closed the file.\n"); return(0); printf("The variable is now: %d\n", variable); if (read(fd, &ch, 1) < 0) { perror("READ failed"); return(1); printf("Read from the file: %s\n", &ch); | return(0); d. [6] Assume that a file "test.file" exists and the file has only one word "Hello" in its first line. What is the message do you seen after running the following C program: #include <stdio.h> #include <string.h> #include <sys/types.h> #include <fcntl.h> int main(int argc, char *argv[]) { pid t chpid; int fd, variable, status; char ch; variable = 9; fd = open("test.file", O_RDONLY); chpid = fork(); if (choid != 0) { } else { /* Executed only by the child */ variable = 42; } wait(&status); } close(fd); printf("The child has changed the variable to: %d\n", variable); printf("The child has also closed the file.\n"); return(0); printf("The variable is now: %d\n", variable); if (read(fd, &ch, 1) < 0) { perror("READ failed"); return(1); printf("Read from the file: %s\n", &ch); | return(0);
Expert Answer:
Answer rating: 100% (QA)
Answer include include include include include Include for fork wait and close f... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
Design a Java class that represents a cache with a fixed size. It should support operations like add, retrieve, and remove, and it should evict the least recently used item when it reaches capacity.
-
CANMNMM January of this year. (a) Each item will be held in a record. Describe all the data structures that must refer to these records to implement the required functionality. Describe all the...
-
Solve the equation symbolically. Then solve the related inequality. - - x] S | - H =
-
Why should you generally expect some error when estimating a parameter (e.g., a population mean) by a statistic (e.g., a sample mean)? What is this kind of error called?
-
The cost of a one-carat VS2 clarity, H color diamond from Diamond Source USA is $5600 (Diamond Source website, March 2003). A midwestern jeweler makes calls to contacts in the diamond district of New...
-
Determine if the mixed method aspect is concurrent, sequential,, or nested. Develop a hypothetical research scenario that would necessitate the use of the Mixed Method A-B-A Design. The research will...
-
At the beginning of the year, Plummer's Sports Center bought three used fitness machines from Advantage, Inc. The machines immediately were overhauled, installed, and started operating. The machines...
-
During the early 19th century, the Springfield (Massachu-setts) Armory provided a good example of: an increasing division of labor accounting techniques for wage payments and control of time and...
-
Divide the expressions. 9x-18xy+36xy By
-
Reggie Company on July 1, 201X, had inventory costing $31,500 and during July had net purchases of $67,200. Over the years, Reggie Companys gross profit averaged 43% on sales. Given that the company...
-
Describe CPA WebTrust.
-
Go to http://investor.kelloggs.com/annuals.cfm, to access the Kelloggs 2010 Annual Report. See Note 16 Supplemental Financial Data and find the balance in Allowance for Doubtful Accounts for 2009 and...
-
What are the two major functions of an information system?
-
Go to http://investor.kelloggs.com/annuals.cfm, to access the Kelloggs 2010 Annual Report and locate the consolidated statement of earnings. How much has Selling and General Administrative Expense...
-
4. Solve the following Second Order Differential Equation, if the question provides initial value conditions then use to write your final answer. (a) y" 8y' 9y = 0, y(1) = 1, y'(1) = 0 (b) 4y" 9y...
-
Subprime loans have higher loss rates than many other types of loans. Explain why lenders offer subprime loans. Describe the characteristics of the typical borrower in a subprime consumer loan.
-
Larry Gaines, age 42, sells his personal residence on November 12, 2012, for $144,000. He lived in the house for 7 years. The expenses of the sale are $10,500, and he has made capital improvements of...
-
Clifford Johnson has a limited partnership investment and a rental condominium. Clifford actively manages the rental condominium. During 2012, his share of the loss from the limited partnership was...
-
Greg died on July 1, 2012, and left Lea, his wife, a $50,000 life insurance policy which she elects to receive at $5,000 per year plus interest for 10 years. In the current year, Lea receives $6,200....
-
Cruz Manufacturing Ltds sales slumped badly in 2019. For the first time in its history, it operated at a loss. The companys income statement showed the following results from selling 600 000 units of...
-
The following are emails from various students to Dr. Destiny Sands, who is a professor in the English Department. These students are wondering if Dr. Sands would let them register for her...
-
What are some flawed assumptions about workplace communication? What is the reality for each myth?
Study smarter with the SolutionInn App