'How do I use fgets or getline if I don't have a stream but a file descriptor?

How do I use fgets or getline if I don't have a stream but a file descriptor ?

According to manpage of fgets

It is not advisable to mix calls to input functions from the stdio library with low-level calls to read(2) for the file descriptor associated with the input stream; the results will be undefined and very probably not what you want.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source