I know printf prints to "stdout" how exactly can I change the pointer to a class of mine that i'd prefer to handle the output string? or is it better to just process using sprintf and manage the strings? Would there be any issues with the first method?

Recommended Answers

All 3 Replies

I know printf prints to "stdout" how exactly

By definition on the standard. Beyond that, don't know, don't care. Just need to know that it works....

can I change the pointer to a class of mine that i'd prefer to handle the output string?

What pointer?

>>By definition on the standard.

just to clarify, usually the standard are terminals in computers, but for other things, it could be definitely something else.

To print to another output stream using the C-style printf() functions, you would use fprintf(FILE* fp, const char* fmt, ...) function. However, for C++ it would be preferable to use output stream objects such as ostream, ofstream, ostringstream, etc. You can create your own output stream class that provides the behavior you want.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.