center text

This is a discussion on center text within the C Programming forums, part of the General Programming Boards category; Hi I have a series of printf statements which are displayed on screen; is it possible that i will center ...

  1. #1
    Registered User
    Join Date
    Aug 2009
    Posts
    15

    center text

    Hi

    I have a series of printf statements which are displayed on screen; is it possible that i will center these in the middle of the screen (both horizontal and vertical)?

    Thank you

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    22,901
    No. It's a bit difficult too since the size of a console can vary, so there's no 100% guarantee that you can get it to center.
    Your best shot is to rely on center formulas (ie console_height / 2 - text_height / 2).
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Registered User
    Join Date
    Aug 2009
    Posts
    15
    Hi,

    Thank you for your reply. Do i need to include any library to use the console_height and text_height. Also how can I combine the the result from this function to the printf statement to move it ?

    Thank You

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    22,901
    They are not variables. They are constants (YOU must figure them out, iow).
    As for the how, I'd suggest looking at the printf documentation. It's all a matter of formatting flags (and several \ns).
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #5
    Registered User
    Join Date
    Aug 2009
    Posts
    15
    ok thank you for pointing me in the right direction, i will work on that.

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