Creating a FILE * stream that results in a string

后端 未结 3 1322
星月不相逢
星月不相逢 2020-12-06 13:40

I\'m looking for a way to pass in a FILE * to some function so that the function can write to it with fprintf. This is easy if I want the output t

3条回答
  •  南笙
    南笙 (楼主)
    2020-12-06 14:17

    If portability is not important for you, you can take a look on fmemopen and open_memstream. They are GNU extensions, hence only available on glibc systems. Although it looks like they are part of POSIX.1-2008 (fmemopen and open_memstream).

提交回复
热议问题