how to align text?

This is a discussion on how to align text? within the C++ Programming forums, part of the General Programming Boards category; how do you align a text being shown like to the middle or the right?...

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    2

    how to align text?

    how do you align a text being shown like to the middle or the right?

  2. #2
    I'm Back
    Join Date
    Dec 2001
    Posts
    556
    use gotoxy or other text spacing functions.

    in graphics.h there is centre_text,vert_dir etc etc..

  3. #3
    Registered User
    Join Date
    Feb 2002
    Posts
    2
    thanks for the reply bud but...i am the newbiest of the newbies...i dunnos what you just said =)

    im trying to create a program where it asks you to input anything and it will print of the screen what you just typed but instead, its aligned or justified to the right...

    also i read another topic where it says you can't or have to set a number of spaces to justify something to the right. is that true?

  4. #4
    Registered User
    Join Date
    Feb 2002
    Posts
    33
    I read that you can have anything a certain number of spaces somewhere... let me find it... here it is
    The manipulator to set something a certain number of spaces out it setw(# of spaces out)
    in order for setw to work, you need to include <iomanip.h>.
    here's how it would work
    #include <iostream.h>
    #include <iomanip.h>
    int main(void)
    {
    int a, b, c;
    cout <<"please enter three numbers with different numbers of digets\n";
    cin >>a>>b>>c;
    cout <<"your numbers were, in reverce order:\n" << setw(5)<<c<<"\n"<<setw(5)<<b<<"\n"<<setw(5)<<a<<"\ n";
    return 0;
    }
    well, very simple, but I think this is what you were looking for.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. My text doesn't display
    By joeprogrammer in forum Game Programming
    Replies: 11
    Last Post: 02-23-2006, 10:01 PM
  2. Appending text to an edit control
    By dit6a9 in forum Windows Programming
    Replies: 3
    Last Post: 08-13-2004, 10:52 PM
  3. Text positioning and Text scrolling
    By RealityFusion in forum C++ Programming
    Replies: 3
    Last Post: 08-13-2004, 01:35 AM
  4. Scrolling The Text
    By GaPe in forum C Programming
    Replies: 3
    Last Post: 07-14-2002, 05:33 PM
  5. Replies: 1
    Last Post: 07-13-2002, 06:45 PM

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