如果我没有流但有文件描述符,如何使用 fgets 或 getline ?
根据 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.
最佳答案
您可以使用 read() 函数从文件描述符中读取,这很清楚,从手册页:
read(int fd, void *buf, size_t count); read() attempts to read up to count bytes from file descriptor fd into the buffer starting at buf.
关于c - 如果我没有流但有文件描述符,如何使用 fgets 或 getline?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70872325/