Thread: quick question

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

    quick question

    This problem has been stairing me in the face for a little bit and I know it's probably just an easy fix. But I'm stumped for right now. I'm working in a linux enviroment and I wanna display text to the screen. That is no prob. But after words I would like to reset the location of the active character to the start of the text I just wrote and re-write over it. How abouts do I relocate the active character (or cursor) to the start of the text I just displayed?

    Thanx,
    -Neil

  2. #2
    Banned Troll_King's Avatar
    Join Date
    Oct 2001
    Posts
    1,784
    You probably have to create a window before you can do that. I could be wrong though. I don't know much about Linux.

  3. #3
    Unregistered
    Guest
    I would try an ascii code for the carriage return. This should return the cursor to the beginning of the line instead of scrolling to the next.

    ascii code is 13 dec
    D hex
    015 oct

  4. #4
    Registered User
    Join Date
    Aug 2001
    Posts
    247
    I could be wrong, but if you know the length of the input line, try using a counter when sentence is input, maybe then you could use,
    Code:
    for(i = len; i < 1; i--) printf("\b");
    this I think would clear previous sentence input and put cursor back at the beginning. Just a shot in the dark though.
    hoping to be certified (programming in c)
    here's the news - I'm officially certified.

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Well the simple way is to use ANSI escape sequences for controlling the cursor position

    http://www.viking.delmar.edu/Courses...5L/ANSIsys.htm

    For more features, consider ncurses

    http://www.gnu.org/software/ncurses/ncurses.html

  6. #6
    Registered User
    Join Date
    Feb 2002
    Posts
    31
    heres a small counter program i wrote that might give you an idea as to how to do what you want:

    Code:
    #include <stdio.h>
    
    #define WAIT 9000000 //wait time will vary for different systems
    
    int main(void)
    {
       int x, i, n = 10, back = 1, count;
    
       for(i = 0; i <= 200; ++i)
       {
          for(x = 0; x < back; ++x)
             printf("\b \b");
    
    	 if(i % n == 0)
             {	
    	    ++back;
    	    n *= 10;
             }
    
            printf("%i", i);
            
    	//so you have time to view the number
    	for(count = 0; count < WAIT; ++count);
       }
       return 0;
    }
    hope this helps.

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

    Cool Thanks

    Thanks alot ... I knew it was something simple!

    -Neil

  8. #8
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683
    I htink u can use gotoxy(x cordinat,y cordinate)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Very quick math question
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 10-26-2005, 11:05 PM
  2. very quick question.
    By Unregistered in forum C++ Programming
    Replies: 7
    Last Post: 07-24-2002, 03:48 AM
  3. quick question
    By Unregistered in forum C++ Programming
    Replies: 5
    Last Post: 07-22-2002, 04:44 AM
  4. Quick Question Regarding Pointers
    By charash in forum C++ Programming
    Replies: 4
    Last Post: 05-04-2002, 11:04 AM
  5. Quick question: exit();
    By Cheeze-It in forum C Programming
    Replies: 6
    Last Post: 08-15-2001, 05:46 PM