Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

language C Write the function my_readline ) according to the following specification Requires: * If *bufp is not NULL, then *bufp must point to a

image text in transcribed

language C

Write the function my_readline ) according to the following specification Requires: * If *bufp is not NULL, then *bufp must point to a buffer that wa:s * previously allocated by malloc) or realloc() and *lenp must be less * than or equal to the size of that buffer. k Effects: *Attempts to read a ' '-terminated line from the given file descriptor, *fd. Copies this line, including the ' ', into the buffer referenced * by *bufp. If *bufp is NULL or the current size of the buffer, as given * by *lenp, is too small to store the entire line, then realloc) is * performed on the buffer to enlarge it. The enlarged buffer is returned *by reference uslng bufp. Similarly, the number of characters stored in * the buffer is returned by reference using lenp *Returns 0 upon success. Returns EOF if read() returns an end-of-file * indication before a , ' is encountered. Nonetheless, the buffer * referenced by *bufp will contain all of the characters successfully * read before that end-of-file indication, and *lenp will equal the number of characters in that buffer. Returns the value of errno if * either realloc) returns NULL or read() returns -1. In either case, as *with read() returning an end-of-file indication, the buffer referenced * by *bufp will contain all of the characters successfully read before *the error occurred, and *lenp will equal the number of characters in that buffer. Returns EINVAL if either bufp or lenp is NULL Notes: * In contrast to rio_readlineb), the returned line should not be NUI terminated * The only functions that your implementation may call are read (2) and * realloc(3) int my_readline(int fd, void **bufp, size_t *lenp) FILL THIS IN. */

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals Design And Implementation

Authors: KROENKE DAVID M.

1st Edition

8120322258, 978-8120322257

More Books

Students also viewed these Databases questions

Question

How to solve maths problems with examples

Answered: 1 week ago