Write the code of function rio_get_remaining(rio_t * rp) which returns the number of unread bytes in...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write the code of function rio_get_remaining(rio_t * rp) which returns the number of unread bytes in the rio buffer. Write the code of function rio_get_read(rio_t * rp) which returns the number of already read bytes in the rio buffer. Hint: the difference (larger-smaller)) of two char* pointers is the number of bytes between them. Use these two functions to write the code of function rio_seek(rio_t * rp, int offset) which changes rio_bufptr so that the next call to rio_read() will read characters in the rio buffer starting with the byte at offset from the beginning of the buffer. Function rio_seek should also adjust rio_cnt. Rio_seek should return 0 if successful and -1 if there is an error, such as offset being outside the proper range. Hint: rio_seek should call rio_get_read and rio_get_remaining to calculate the total number of bytes in the rio buffer. Hint: rio_seek should adjust rio_bufptr and rio_cnt based on offset. Write the code of function test(rio_t * rp) that uses rio_read to read the first byte (and fill the rio buffer) and then uses functions rio_seek and rio_read to extract every tenth byte of the file associated with rp, and store these bytes in a local char array. Function test() should only use rio functions. Write the code of function rio_get_remaining(rio_t * rp) which returns the number of unread bytes in the rio buffer. Write the code of function rio_get_read(rio_t * rp) which returns the number of already read bytes in the rio buffer. Hint: the difference (larger-smaller)) of two char* pointers is the number of bytes between them. Use these two functions to write the code of function rio_seek(rio_t * rp, int offset) which changes rio_bufptr so that the next call to rio_read() will read characters in the rio buffer starting with the byte at offset from the beginning of the buffer. Function rio_seek should also adjust rio_cnt. Rio_seek should return 0 if successful and -1 if there is an error, such as offset being outside the proper range. Hint: rio_seek should call rio_get_read and rio_get_remaining to calculate the total number of bytes in the rio buffer. Hint: rio_seek should adjust rio_bufptr and rio_cnt based on offset. Write the code of function test(rio_t * rp) that uses rio_read to read the first byte (and fill the rio buffer) and then uses functions rio_seek and rio_read to extract every tenth byte of the file associated with rp, and store these bytes in a local char array. Function test() should only use rio functions.
Expert Answer:
Answer rating: 100% (QA)
include stdio h include stdlib h define RIOBUFSIZE 8192 typedef struct int riofd Descriptor for this ... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
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...
-
Python and most Python libraries are free to download or use, though many users use Python through a paid service. Paid services help IT organizations manage the risks associated with the use of...
-
Consider the following function. def f(x): a = [] while x > 0: a.append(x) f(x-1) A new object of type list is created for each recursive invocation of f. True or False
-
Suppose that I = 15 and c = 5 for the I controller with internal feedback shown in Figure 10.6.6. The performance specifications require that = 0.5. (a) Compute the required gain values for each of...
-
A heat engine receives 75.0 MJ from a thermal reservoir and rejects 975 kJ over a 1 hour interval. What is the output power of the engine?
-
Explain with the help of neat sketches, the working of two stroke petrol engine.
-
The Lockit Company manufactures door knobs for residential homes and apartments. Lockit is considering the use of simple (single-driver) and multiple regression analyses to forecast annual sales...
-
In light of your personal experience, what strategies or approaches do you believe could be effective in creating a workplace environment where employees from diverse cultural backgrounds feel both...
-
An artificial satellite is moving in a circular orbit of radius 42250 km. What is its speed if it takes 24 hours to revolve around the earth? Options: 1) 11065.48 km/h 2) 1245.98 km/h 3) 56248.36...
-
Nonverbal - Skeleton Name____________________________________ The purpose of this assignment is to help you demonstrate the following Student Learning Outcome(s) 1. Demonstrate and explain an...
-
A project costs $80 MM, with 25% of the investment int in year 1 and the balance in year 2. The plant operates atates at 50% capacity in year 3 and then full capacity for the next next 20 years. The...
-
How do change agents leverage data analytics and predictive modeling to anticipate potential barriers and proactively design interventions that facilitate smoother transitions and minimize disruption...
-
The price of a product changes from $8 to $9, and as a result, the quantity of the product demanded falls from 20 to 15. What do you know about the price elasticity of this good?
-
Express the limit below as a definite integral. The n points Xo
-
Wars Airbornes strategy of using strategic alliances to expand overseas wise What were the pros and cons of this strategy? Read the case study Airborne Express: Underdog and answer the question:
-
On January 1, 2017, McIlroy, Inc., acquired a 60 percent interest in the common stock of Stinson, Inc., for $340,200. Stinson's book value on that date consisted of common stock of $100,000 and...
-
What is the direction of the magnetic field at a point vertically (a) above (b) below segment 1 in Figure 28.5? Figure 28.5 Mapping the magnetic field of a current loop. The magnetic field...
-
Make a sketch showing the directions of the magnetic forces exerted on each other by (a) an electron moving in the same direction as the current through a wire, (b) a moving charged particle and a...
-
As the current loop in Figure 28.10 rotates over the first \(90^{\circ}\), do the magnitudes of (a) the magnetic force exerted on the horizontal sides and (b) the torque caused by these forces...
Study smarter with the SolutionInn App