cout manipulation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mar11
    New Member
    • Sep 2009
    • 38

    cout manipulation

    Hi all,

    i have the following example for manipulation the output

    cout <<"*** the value"<< setw (10)<<"okay"<<e ndl;
    cout <<"******* the value"<< setw (10)<<"okay"<<e ndl;

    and i get this output:

    *** the value okay
    ******* the value okay

    my question is, how can i manipulate the cout to get the output something like that:

    *** the value okay
    ******* the value okay

    that means i need to count from the begin of the line and not from the end of the first string ...

    thanks for each support
  • whodgson
    Contributor
    • Jan 2007
    • 542

    #2
    Do you have <iomanip> or <iomanip.h> included?

    Comment

    • mar11
      New Member
      • Sep 2009
      • 38

      #3
      yes...

      i mean, i want to get the output at this way... again, i need to count from the begin of the line and not from the end of the first string ...

      Code:
      *** the value                      okay
      ******* the value                  okay

      Comment

      • mar11
        New Member
        • Sep 2009
        • 38

        #4
        is this quetion realy difficult to answer :(

        Comment

        • weaknessforcats
          Recognized Expert Expert
          • Mar 2007
          • 9214

          #5
          It would help if:

          *** the value
          ******* the value

          were the same length. You might use a set manipulator to set the fields width for this data. The set(10) in your example is for okay only.

          Or, create a string with this data in it and pad spaces to the right so that the string when displayed is always the same length.

          Comment

          Working...