John Harrison wrote:
[snip]
You cannot. If you can switch to using C++ I/O where this is REALLY EASY,
instead of using FILE, where it is COMPLETELY IMPOSSIBLE.
That is a qualified "COMPLETELY IMPOSSIBLE", meaning that within the confines
of proper and portable C++, it isn't possible.
However, there may be ways to accomplish what you desire using operating-system
specific file i/o hooks and/or other hacking & subterfuge -- BUT, these should
only be considered as a last resort, and only by someone that fully understands
the implementation details, implications, and ramifications of such hacking.
Something else that could be considered is how the library is linked in -- if
it is a library in the traditional sense (static link), the OP may be able to
provide specialized implementations of the standard file i/o functions (say,
fputs) and they redirect the output to memory. Depending on how your compiler
performs and resolves the link, this may or may not work. Again, an advanced
(hack) method that has all sorts of caveats.