I have a bad opinion that the answer to this question is no, but I wanted to drop it there if anyone has smart ideas.
I have a set of output procedures that occupy a complex data structure and print it in text format. They have prototypes like:
void print_mystruct(struct mystruct *s, FILE *stream)
I wrote this so that I can get efficient, buffered output to the terminal, to a file, to the network, etc.
Unfortunately, I do not know, using the standard C99, that I can use the same procedures to create a string in memory.
So my questions are:
- Is there any smart way that I can use the functions fputs (), fprintf (), etc. for output to a string?
- , , , ? , , - vtable ( FILE *). vtable , , fwrite. printf.
?
EDIT: , fmemopen() POSIX.1-2008 (.: fmemopen()), , , man- GNU libc.