print to end of line in a terminal

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ndlarsen
    New Member
    • Feb 2008
    • 1

    print to end of line in a terminal

    Hey.

    This might seem as a arbitrary question to some. Anyway, I'm wondering how I go about printing text to the end of a line in a terminal/console. I've been googling it for a few days without any success. Any suggestions will be greatly appreciated.
    Regards
  • dazzler
    New Member
    • Nov 2007
    • 75

    #2
    Originally posted by ndlarsen
    Hey.

    This might seem as a arbitrary question to some. Anyway, I'm wondering how I go about printing text to the end of a line in a terminal/console. I've been googling it for a few days without any success. Any suggestions will be greatly appreciated.
    Regards
    do you mean that you want to print overwriting old text to same line without making new line? like a progress meter going from 0% to 100% ?

    Comment

    • mschenkelberg
      New Member
      • Jun 2007
      • 44

      #3
      I was wondering about that too, except not same line. Scenario where program gets user input from stdin and instead of outputting result on next line, output same line user entered input.

      Normally this happens because user must press enter to submit text
      ./test
      Please enter a number: 32
      You entered 32.

      I would like to do this:
      ./test
      Please enter a number: 32 You entered 32.

      Comment

      Working...