Write the program in C. Create your own fgets() and fputs() using only Unix system calls such
Fantastic news! We've Found the answer you've been seeking!
Question:
Write the program in C. Create your own fgets() and fputs() using only Unix system calls such as open, read, write, close etc, so no standard input/outputs functions are allowed.
Transcribed Image Text:
Using only the Unix input/output system calls(do not use any standard input/output functions), define two C functions, called myFgets() and myFputs() with the following requirements: • int myFgets(char *s, int size, int stream): reads in at most one less than size characters from stream (file descriptor is stream) and stores them into the buffer pointed to by s. Reading stops after an EOF or a newline (i.e., reading should be done one byte at a time). If a newline is read, it is stored into the buffer. A terminating null byte is stored after the last character in the buffer. This function returns the number of characters read or, 0 for end of file or -1 in case of error. • int my Fputs(const char *s, int *stream), writes the string s to stream, without its terminating null byte. This function returns the number of characters written or -1 in case of error. Then, define your main function to perform a copy task using your defined functions, myFgets() and myF- puts(). Your C program takes two arguments, input file and destination file. Using only the Unix input/output system calls(do not use any standard input/output functions), define two C functions, called myFgets() and myFputs() with the following requirements: • int myFgets(char *s, int size, int stream): reads in at most one less than size characters from stream (file descriptor is stream) and stores them into the buffer pointed to by s. Reading stops after an EOF or a newline (i.e., reading should be done one byte at a time). If a newline is read, it is stored into the buffer. A terminating null byte is stored after the last character in the buffer. This function returns the number of characters read or, 0 for end of file or -1 in case of error. • int my Fputs(const char *s, int *stream), writes the string s to stream, without its terminating null byte. This function returns the number of characters written or -1 in case of error. Then, define your main function to perform a copy task using your defined functions, myFgets() and myF- puts(). Your C program takes two arguments, input file and destination file.
Expert Answer:
Answer rating: 100% (QA)
To Define two C functions myFgets and myFputs using Unix inputoutput system calls There is a problem ... View the full answer
Related Book For
Management Accounting Information for Decision-Making and Strategy Execution
ISBN: 978-0137024971
6th Edition
Authors: Anthony A. Atkinson, Robert S. Kaplan, Ella Mae Matsumura, S. Mark Young
Posted Date:
Students also viewed these operating system questions
-
The boom has a length of 30 ft, a weight of 800 lb, and mass center at G. (Figure 1) Figure 1 If the maximum moment that can be developed by a motor at A is M=20(103) lb-ft, determine the maximum...
-
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...
-
The fixed budget for 21,300 units of production shows sales of $468,600; variable costs of $63,900; and fixed costs of $143,000. The company's actual sales were 26,300 units at $531,600. Actual...
-
Juanita Torres is 35-years old and lately has been working with her financial planner. She is attempting develop a long-term savings and investment program. She has been thinking about all the major...
-
In the Bohr model of the hydrogen atom what is the smallest amount of work that must be done on the electron to move it from its circular orbit, with a radius of 0.529 10-10 m, to an infinite...
-
Skillful Scanners produces commercial scanners. Throughout 2000, unit variable cost remained constant and fixed overhead was applied at the rate of $5 per unit. Income before tax using the variable...
-
Helgeson Enterprises, Corp., completed the following selected transactions and prepared these adjusting entries during January: 2. Compute January net income or net loss under the accrual basis of...
-
A recent annual report for FedEx included the following note: Property and Equipment Expenditures for major additions, improvements, flight equipment modifications, and certain equipment overhaul...
-
Ted and Julia Higgins are married for all of 2023 with an AGI of $140,000, Taxable Income of $100,000 and Tax Liability of $30,000. Their income includes $20,000 of dividends Ted earned from...
-
Better Fitness, Inc. (BFI) manufactures exercise equipment at its plant in Freeport, Long Island. It recently designed two universal weight machines for the home exercise market. Both machines use...
-
Case Write-Up #1: Marketing Chateau Margaux Please be concise in your case write-up: find the problem, assess why it happened, and propose a solution. Use the following questions as a guideline for...
-
Consider the chemical reaction: aPbNe+bCrMnOscCrO3 +dMnO + ePbO4 + NO (a) Write out a system of equations that can be used to balance the reaction. (b) Find the general solution to the system from...
-
You are the new Rooms / F&B Division Director ( chose 1 ) of a prestigious XX star luxury hotel in Barcelona named " La Pasin ". You have been hired a week ago to fill the position and within your...
-
What is the role of leadership in driving organizational effectiveness, and what leadership styles tend to foster a culture of high performance and continuous improvement ?
-
What is the mass of a suitcase in pounds if it weighs 19.5 kilograms? (1 kg = 2.205 lb) Use the correct number of significant figures and do not put in scientific notation. D Question 5 1 pts If a...
-
Part A A 6.00 A current runs through a 12 gauge copper wire (diameter 2.05 mm) and through a light bulb. Copper has 8.5 x 1028 free electrons per cubic meter. How many electrons pass through the...
-
2. (a) (b) (c) Sarah has a 8-year investment horizon. She is considering purchasing a 12-year, 10% coupon bond. Coupon payments are made semi-annually and the bond has a face value of 1,000. The bond...
-
The relationship described in question 7 does not always appear to hold. What factors, besides the number of firms in the market, might affect margins?
-
Baden is a city with a population of 450,000. It has a distinct organization group, called the Public Utilities Commission of the city of Baden, or Baden PUC, whose responsibility is to provide the...
-
Based on your understanding, which of the following does the manager of a cinema control: costs, revenues, profits, and investment?
-
How is residual income computed?
-
What is the relative frequency of direct hits that were AT MOST a category 3 storm? a. 0.3480 b. 0.9231 c. 0.2601 d. 0.3370 Table 1.18 contains data on hurricanes that have made direct hits on the...
-
A survey of 250 members from an organized union of over 20,000 members. In Exercises 1120, determine whether the data set is a population or a sample. Explain your reasoning.
-
The carbon monoxide levels of 12 of 49 people who escaped a burning building. In Exercises 1120, determine whether the data set is a population or a sample. Explain your reasoning.
Study smarter with the SolutionInn App