Thread: How to print our text at given coordinates?

  1. #1
    Registered User
    Join Date
    Oct 2007
    Posts
    47

    How to print our text at given coordinates?

    Hi, how do I do this in c?

    That is I want to print out something at 0,10. For example

    CPU load: 50%

    And I want to update "50%" very often and I don't want to redraw the whole screen, just that space that holds the %, how do I solve this in c?

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    ncurses, if you are doing this on a Unix-like system.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Oct 2007
    Posts
    47
    ok, so I can't do it with printf? just want to print text at a given position.

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Not without a whole heap of system dependancy. I think most X-terms use VT100 terminal emulation, which means you could send some "Escape sequences" to place the cursor - look it up.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    Registered User Tommo's Avatar
    Join Date
    Jun 2007
    Location
    Scotland
    Posts
    101

  6. #6
    and the hat of copycat stevesmithx's Avatar
    Join Date
    Sep 2007
    Posts
    587
    Unix does not support gotoxy() function.
    Not everything that can be counted counts, and not everything that counts can be counted
    - Albert Einstein.


    No programming language is perfect. There is not even a single best language; there are only languages well suited or perhaps poorly suited for particular purposes.
    - Herbert Mayer

  7. #7
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by stevesmithx View Post
    Unix does not support gotoxy() function.

    Yes, of course it does - there's just no predefined gotoxy() function - doesn't mean that you can't create one, like the above link. And I think the ANSI escape sequences are compatible enough to work on a VT100 compatible window.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  8. #8
    and the hat of copycat stevesmithx's Avatar
    Join Date
    Sep 2007
    Posts
    587
    Sorry didnt notice it as an user defined function.
    gotoxy() reminded me Turbo C library's <conio.h> function.
    Last edited by stevesmithx; 10-25-2007 at 07:31 AM.
    Not everything that can be counted counts, and not everything that counts can be counted
    - Albert Einstein.


    No programming language is perfect. There is not even a single best language; there are only languages well suited or perhaps poorly suited for particular purposes.
    - Herbert Mayer

  9. #9
    Registered User
    Join Date
    Oct 2007
    Posts
    47
    thanks guys, exactly what I needed.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. DirectX | Drawing text
    By gavra in forum Game Programming
    Replies: 4
    Last Post: 06-08-2009, 12:23 AM
  2. A bunch of Linker Errors...
    By Junior89 in forum Windows Programming
    Replies: 4
    Last Post: 01-06-2006, 02:59 PM
  3. reading from text file
    By jamez in forum C Programming
    Replies: 3
    Last Post: 11-30-2005, 07:13 PM
  4. How to use FTP?
    By maxorator in forum C++ Programming
    Replies: 8
    Last Post: 11-04-2005, 03:17 PM
  5. Small HTML question
    By Thantos in forum Tech Board
    Replies: 4
    Last Post: 12-29-2003, 12:37 AM