how do i center text using iosflags

This is a discussion on how do i center text using iosflags within the C++ Programming forums, part of the General Programming Boards category; i need to center text in a field that is 50 characters wide ....... this is for a school project, ...

  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    1

    how do i center text using iosflags

    i need to center text in a field that is 50 characters wide ....... this is for a school project, so it has to be centered using iosflags since that is the only way the teacher has tought us how to do it.

    ~thanks~

  2. #2
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    To my knowledge, you cannot center text using ios flags. Try something like this:

    Code:
    void Center(string &text, ostream &of)
    {
       for (int i = 0; i < 50 - text.length(); i++) of.put(' ');
       of << text;
    }
    Last edited by Eibro; 11-10-2002 at 03:31 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Text adventure engine idea. thoughts?
    By suzakugaiden in forum Game Programming
    Replies: 16
    Last Post: 01-15-2006, 05:13 AM
  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