User Profile

Collapse

Profile Sidebar

Collapse
Johanus Dagius
Johanus Dagius
Last Activity: Jun 27 '07, 10:44 AM
Joined: Jun 22 '07
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • Johanus Dagius
    replied to Need manipulator to set maximum I/O width
    in C
    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...
    See more | Go to post

    Leave a comment:


  • Johanus Dagius
    replied to Need manipulator to set maximum I/O width
    in C
    >>> 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...
    See more | Go to post

    Leave a comment:


  • Johanus Dagius
    started a topic Need manipulator to set maximum I/O width
    in C

    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:
    Code:
    printf("s=%.10s\n", very_long_string).
    How do I do this with C++ manipulators? I've tried std::setw(width ), but it seems to control only...
    See more | Go to post
No activity results to display
Show More
Working...