weaknessforcats wrote:
>>> The problem with a max manipulator is that it requires fiddling with the
>>> private data of ios_base. setw() calls ios_base::width (). You would have to
>>> derive from ios_base, or more likely, from basic_ostream to add these features ....
Hey, thanks for the partial solution. (It works!) I really appreciate your efforts here to help me, but I think I'll...
User Profile
Collapse
-
>>> Then write your own manipulator ...
OK, I understand your simple manipulator, which merely inserts and returns its own stuff into the output stream.
But I don't see how it can truncate output(s) further down the stream. I suspect this is not trivial thing to do. Would appreciate if someone could give me some pointers on how to do this (or even better: write the maxw(n) code for me :-)
I must say...Leave a comment:
-
Need manipulator to set maximum I/O width
I've written a lot of C programs but only a few in C++. In C you can set both the minimum and maximum width of a formatted I/O output by using standard printf() formats. For example, if I have a very large string and I only want to print out the first 10 chars I can do this in C:
How do I do this with C++ manipulators? I've tried std::setw(width ), but it seems to control only...Code:printf("s=%.10s\n", very_long_string).
No activity results to display
Show More
Leave a comment: