cout

This is a discussion on cout within the C++ Programming forums, part of the General Programming Boards category; how can I print exactly like this: 1234 5 23 10 5 600 notice how the numbers in the second ...

  1. #1
    Max
    Max is offline
    Registered User Max's Avatar
    Join Date
    Jul 2002
    Posts
    110

    cout

    how can I print exactly like this:

    1234 5
    23 10
    5 600

    notice how the numbers in the second column are alligned

    I don't want to print like this

    1234 5
    23 10
    5 600

    Thanks?


    [code][/code]tagged by Salem
    @Max - re-edit this post to get the effect you want with code tags around the formatted text
    Last edited by Max; 12-21-2002 at 02:50 PM.

  2. #2
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    What's the difference?

  3. #3
    Registered User The Junglist's Avatar
    Join Date
    Nov 2002
    Posts
    42
    Hmmmm........ it seems as if extra white spaces are automatically trimmed.

    Max, I know what you're asking, and you should try using the '\t' escape character.

  4. #4
    Max
    Max is offline
    Registered User Max's Avatar
    Join Date
    Jul 2002
    Posts
    110
    odd...someone played with my original post??!!!??

    basically what I am trying to do is change this c code into c++

    if (k%2==0) printf("%*s", -LINEWIDTH/2,t[k]);
    else printf("%s\n",t[k]);

    It prints values in two columns all numbers in the second column are alligned exactly under each others i think it is called left justified.

    how do I do that?

  5. #5
    Max
    Max is offline
    Registered User Max's Avatar
    Join Date
    Jul 2002
    Posts
    110
    It did not work..........

  6. #6
    Max
    Max is offline
    Registered User Max's Avatar
    Join Date
    Jul 2002
    Posts
    110
    It did not work!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. class methods to cout stream
    By shintaro in forum C++ Programming
    Replies: 5
    Last Post: 11-11-2008, 06:27 PM
  2. cout vs std::cout
    By none in forum C++ Programming
    Replies: 10
    Last Post: 07-26-2004, 11:20 PM
  3. changing cout output
    By Yohumbus in forum C++ Programming
    Replies: 1
    Last Post: 10-23-2002, 04:09 AM
  4. Redirecting cout stream
    By Arrow Mk84 in forum C++ Programming
    Replies: 1
    Last Post: 10-08-2002, 04:17 PM
  5. printf vs cout
    By RyeDunn in forum C++ Programming
    Replies: 5
    Last Post: 07-09-2002, 04:26 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21