Get Buffering Parameters From an Open `FILE*`

六眼飞鱼酱① 提交于 2020-06-08 19:16:18

问题


In C, we can use setvbuf(...) to set a buffer, its size, and a buffering mode. I am surprised to find that no one has asked how to read these values, given an open FILE* (e.g. stdout, or user-provided). I.e., how could one implement a "getvbuf(...)" routine (or even a subset of it)?

void getvbuf(FILE* stream, char** pbuf,int* bufmode,size_t* bufsize);

回答1:


I don't think its available as part of the standard. However Solaris has introduced some non standard mechanism to query few of these properties which are also available in GNU C compiler.

Check this for more details: https://www.gnu.org/software/libc/manual/html_node/Controlling-Buffering.html

I was curious to know the use case where you want to do a getvbuf(..) kind of stuff.



来源:https://stackoverflow.com/questions/41197000/get-buffering-parameters-from-an-open-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!