Question: 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

   Write the code of function rio_get_remaining(rio_t * rp) which returns the number  

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.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

include stdio h include stdlib h define RIOBUFSIZE 8192 typedef struct int riofd Descriptor for this ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!