How to update a printed message in terminal without reprintingHow to update a output field in terminal without output a new line?Output multiple chacters to the same location in the Windows command console without overwritingC++ Update console outputDisplay a single line to stdout that updates a portion instead of printing a new line in Ctext being rewritten for 1000 times?Modify text already in the terminalProgressbar C++How would I overwrite a printed 2D array to simulate 'updates'How to print colored text in terminal in Python?How do I reload .bashrc without logging out and back in?How do I output coloured text to a Linux terminal?Printing to a progress bar to the terminal from Java/C++How do I clear/delete the current line in terminal?Image Processing: Algorithm Improvement for 'Coca-Cola Can' RecognitionHow to update a output field in terminal without output a new line?How to get the current date and time in the terminal and set a custom command in terminal for it?Linux Printing - How ToCommand line progress bar with other output

Why does it output Integers instead of letters?

Changing trains in the Netherlands

If your plane is out-of-control, why does military training instruct releasing the joystick to neutralize controls?

Keep milk (or milk alternative) for a day without a fridge

How many hours would it take to watch all of Doctor Who?

Why isn't pressure filtration popular compared to vacuum filtration?

Terry Pratchett book with a lawyer dragon and sheep

How can I effectively communicate to recruiters that a phone call is not possible?

Storming Area 51

Is a bass line the same as a bass note progression?

The monorail explodes before I can get on it

How to wire 3 hots / 3 neutrals into this new TR outlet with 2 screws?

How do you glue a text to a point?

Matchmaker, Matchmaker, make me a match

Machine learning and operations research projects

Are randomly-generated passwords starting with "a" less secure?

How would vampires avoid contracting diseases?

How can one write good dialogue in a story without sounding wooden?

Why do players in the past play much longer tournaments than today's top players?

Does Lufthansa weigh your carry on luggage?

Do you know your 'KVZ's?

Why didn't Thanos kill all the Dwarves on Nidavellir?

Is the genetic term "polycistronic" still used in modern biology?

RPI3B+: What are the four components below the HDMI connector called?



How to update a printed message in terminal without reprinting


How to update a output field in terminal without output a new line?Output multiple chacters to the same location in the Windows command console without overwritingC++ Update console outputDisplay a single line to stdout that updates a portion instead of printing a new line in Ctext being rewritten for 1000 times?Modify text already in the terminalProgressbar C++How would I overwrite a printed 2D array to simulate 'updates'How to print colored text in terminal in Python?How do I reload .bashrc without logging out and back in?How do I output coloured text to a Linux terminal?Printing to a progress bar to the terminal from Java/C++How do I clear/delete the current line in terminal?Image Processing: Algorithm Improvement for 'Coca-Cola Can' RecognitionHow to update a output field in terminal without output a new line?How to get the current date and time in the terminal and set a custom command in terminal for it?Linux Printing - How ToCommand line progress bar with other output






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








39















I want to make a progress bar for my terminal application that would work something like:



 [XXXXXXX ] 


which would give a visual indication of how much time there is left before the process completes.



I know I can do something like printing more and more X's by adding them to the string and then simply printf, but that would look like:



 [XXXXXXX ] 
[XXXXXXXX ]
[XXXXXXXXX ]
[XXXXXXXXXX ]


or something like that (obviously you can play with the spacing.) But this is not visually aesthetic. Is there a way to update the printed text in a terminal with new text without reprinting? This is all under linux, c++.










share|improve this question






























    39















    I want to make a progress bar for my terminal application that would work something like:



     [XXXXXXX ] 


    which would give a visual indication of how much time there is left before the process completes.



    I know I can do something like printing more and more X's by adding them to the string and then simply printf, but that would look like:



     [XXXXXXX ] 
    [XXXXXXXX ]
    [XXXXXXXXX ]
    [XXXXXXXXXX ]


    or something like that (obviously you can play with the spacing.) But this is not visually aesthetic. Is there a way to update the printed text in a terminal with new text without reprinting? This is all under linux, c++.










    share|improve this question


























      39












      39








      39


      13






      I want to make a progress bar for my terminal application that would work something like:



       [XXXXXXX ] 


      which would give a visual indication of how much time there is left before the process completes.



      I know I can do something like printing more and more X's by adding them to the string and then simply printf, but that would look like:



       [XXXXXXX ] 
      [XXXXXXXX ]
      [XXXXXXXXX ]
      [XXXXXXXXXX ]


      or something like that (obviously you can play with the spacing.) But this is not visually aesthetic. Is there a way to update the printed text in a terminal with new text without reprinting? This is all under linux, c++.










      share|improve this question
















      I want to make a progress bar for my terminal application that would work something like:



       [XXXXXXX ] 


      which would give a visual indication of how much time there is left before the process completes.



      I know I can do something like printing more and more X's by adding them to the string and then simply printf, but that would look like:



       [XXXXXXX ] 
      [XXXXXXXX ]
      [XXXXXXXXX ]
      [XXXXXXXXXX ]


      or something like that (obviously you can play with the spacing.) But this is not visually aesthetic. Is there a way to update the printed text in a terminal with new text without reprinting? This is all under linux, c++.







      c++ linux text terminal






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 26 at 2:30









      jww

      56.3k42 gold badges249 silver badges540 bronze badges




      56.3k42 gold badges249 silver badges540 bronze badges










      asked Aug 26 '09 at 21:14









      ldogldog

      6,6738 gold badges45 silver badges65 bronze badges




      6,6738 gold badges45 silver badges65 bronze badges






















          8 Answers
          8






          active

          oldest

          votes


















          43














          try using r instead of n when printing the new "version".



          for(int i=0;i<=100;++i) printf("r[%3d%%]",i);
          printf("n");





          share|improve this answer























          • works like a charm, thanks

            – ldog
            Aug 26 '09 at 21:32


















          10














          I'd say that a library like ncurses would be used to such things. curses helps move the cursor around the screen and draw text and such.



          NCurses






          share|improve this answer


















          • 6





            Sounds like an overkill here.

            – Michael Krelin - hacker
            Aug 26 '09 at 21:20






          • 1





            Yeah, probably...just a suggestion if someone wants to get more fancy in the future ;)

            – KFro
            Aug 26 '09 at 21:23






          • 3





            Yeah... there could be a game of PONG going on while we wait for the progress bar. :D

            – kjfletch
            Aug 26 '09 at 21:30











          • thanks for the tip ;) I know about ncurses, I've used it before to make a terminal hangman game, but I wanted to ask around before using it cause I knew it was overkill

            – ldog
            Aug 26 '09 at 21:33


















          7














          Something like this:



          std::stringstream out;
          for (int i = 0; i< 10; i++)

          out << "X";
          cout << "r" << "[" << out.str() << "]";



          The sneaky bit is the carriage return character "r" which causes the cursor to move to the start of the line without going down to the next line.






          share|improve this answer






























            3














            Others have already pointed out that you can use r to go back to the beginning of the current line, and overwrite the entire line.



            Another possibility is to use the backspace character ("b") to erase a few spaces, and overwrite only those spaces. This can have a couple of advantages. First, it obviously avoids having to regenerate everything in the line, which can sometimes be mildly painful (though that is fairly unusual). Second, it can avoid some pain in displaying data that (for one example) shrinks in size as you write it -- for example, if you're displaying a count-down from 100 to 0, with r you have to be careful about overwriting the entire previous length, or your countdown will go from (for example) 100 to 990 (i.e., leaving the previous "0" intact).



            Note, however, that while back-space within a line normally works, a backspace at the beginning of a line may or may not move the cursor/write position back to a previous line. For most practical purposes, you can only move around within a single line.






            share|improve this answer






























              1














              'r' will perform a carriage return. Imagine a printer doing a carriage return without a linefeed ('n'). This will return the writing point back to the start of the line... then reprint your updated status on top of the original line.






              share|improve this answer






























                1














                It's a different language, but this question might be of assistance to you. Basically, the escape character r (carriage Return, as opposed to n Newline) moves you back to the beginning of your current printed line so you can overwrite what you've already printed.






                share|improve this answer
































                  1














                  Another option is to simply print one character at a time. Typically, stdout is line buffered, so you'll need to call fflush(stdout) --



                  for(int i = 0; i < 50; ++i) 
                  putchar('X'); fflush(stdout);
                  /* do some stuff here */

                  putchar('n');


                  But this doesn't have the nice terminating "]" that indicates completion.






                  share|improve this answer






























                    0














                    I've written this loading bar utility some time ago. Might be useful...



                    https://github.com/BlaDrzz/CppUtility/tree/master/LoadingBar



                    You can customise basically anything in here.



                    int max = 1000;
                    LoadingBar* lb = new LoadingBar(10, 0, max);

                    for (size_t i = 0; i <= max; i++)

                    lb->print();
                    lb->iterate();

                    cout << lb->toString() << endl;


                    Very simple and customisable implementation..






                    share|improve this answer

























                      Your Answer






                      StackExchange.ifUsing("editor", function ()
                      StackExchange.using("externalEditor", function ()
                      StackExchange.using("snippets", function ()
                      StackExchange.snippets.init();
                      );
                      );
                      , "code-snippets");

                      StackExchange.ready(function()
                      var channelOptions =
                      tags: "".split(" "),
                      id: "1"
                      ;
                      initTagRenderer("".split(" "), "".split(" "), channelOptions);

                      StackExchange.using("externalEditor", function()
                      // Have to fire editor after snippets, if snippets enabled
                      if (StackExchange.settings.snippets.snippetsEnabled)
                      StackExchange.using("snippets", function()
                      createEditor();
                      );

                      else
                      createEditor();

                      );

                      function createEditor()
                      StackExchange.prepareEditor(
                      heartbeatType: 'answer',
                      autoActivateHeartbeat: false,
                      convertImagesToLinks: true,
                      noModals: true,
                      showLowRepImageUploadWarning: true,
                      reputationToPostImages: 10,
                      bindNavPrevention: true,
                      postfix: "",
                      imageUploader:
                      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                      allowUrls: true
                      ,
                      onDemand: true,
                      discardSelector: ".discard-answer"
                      ,immediatelyShowMarkdownHelp:true
                      );



                      );













                      draft saved

                      draft discarded


















                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f1337529%2fhow-to-update-a-printed-message-in-terminal-without-reprinting%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown

























                      8 Answers
                      8






                      active

                      oldest

                      votes








                      8 Answers
                      8






                      active

                      oldest

                      votes









                      active

                      oldest

                      votes






                      active

                      oldest

                      votes









                      43














                      try using r instead of n when printing the new "version".



                      for(int i=0;i<=100;++i) printf("r[%3d%%]",i);
                      printf("n");





                      share|improve this answer























                      • works like a charm, thanks

                        – ldog
                        Aug 26 '09 at 21:32















                      43














                      try using r instead of n when printing the new "version".



                      for(int i=0;i<=100;++i) printf("r[%3d%%]",i);
                      printf("n");





                      share|improve this answer























                      • works like a charm, thanks

                        – ldog
                        Aug 26 '09 at 21:32













                      43












                      43








                      43







                      try using r instead of n when printing the new "version".



                      for(int i=0;i<=100;++i) printf("r[%3d%%]",i);
                      printf("n");





                      share|improve this answer













                      try using r instead of n when printing the new "version".



                      for(int i=0;i<=100;++i) printf("r[%3d%%]",i);
                      printf("n");






                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Aug 26 '09 at 21:17









                      Michael Krelin - hackerMichael Krelin - hacker

                      95.3k14 gold badges167 silver badges157 bronze badges




                      95.3k14 gold badges167 silver badges157 bronze badges












                      • works like a charm, thanks

                        – ldog
                        Aug 26 '09 at 21:32

















                      • works like a charm, thanks

                        – ldog
                        Aug 26 '09 at 21:32
















                      works like a charm, thanks

                      – ldog
                      Aug 26 '09 at 21:32





                      works like a charm, thanks

                      – ldog
                      Aug 26 '09 at 21:32













                      10














                      I'd say that a library like ncurses would be used to such things. curses helps move the cursor around the screen and draw text and such.



                      NCurses






                      share|improve this answer


















                      • 6





                        Sounds like an overkill here.

                        – Michael Krelin - hacker
                        Aug 26 '09 at 21:20






                      • 1





                        Yeah, probably...just a suggestion if someone wants to get more fancy in the future ;)

                        – KFro
                        Aug 26 '09 at 21:23






                      • 3





                        Yeah... there could be a game of PONG going on while we wait for the progress bar. :D

                        – kjfletch
                        Aug 26 '09 at 21:30











                      • thanks for the tip ;) I know about ncurses, I've used it before to make a terminal hangman game, but I wanted to ask around before using it cause I knew it was overkill

                        – ldog
                        Aug 26 '09 at 21:33















                      10














                      I'd say that a library like ncurses would be used to such things. curses helps move the cursor around the screen and draw text and such.



                      NCurses






                      share|improve this answer


















                      • 6





                        Sounds like an overkill here.

                        – Michael Krelin - hacker
                        Aug 26 '09 at 21:20






                      • 1





                        Yeah, probably...just a suggestion if someone wants to get more fancy in the future ;)

                        – KFro
                        Aug 26 '09 at 21:23






                      • 3





                        Yeah... there could be a game of PONG going on while we wait for the progress bar. :D

                        – kjfletch
                        Aug 26 '09 at 21:30











                      • thanks for the tip ;) I know about ncurses, I've used it before to make a terminal hangman game, but I wanted to ask around before using it cause I knew it was overkill

                        – ldog
                        Aug 26 '09 at 21:33













                      10












                      10








                      10







                      I'd say that a library like ncurses would be used to such things. curses helps move the cursor around the screen and draw text and such.



                      NCurses






                      share|improve this answer













                      I'd say that a library like ncurses would be used to such things. curses helps move the cursor around the screen and draw text and such.



                      NCurses







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Aug 26 '09 at 21:19









                      KFroKFro

                      6993 silver badges8 bronze badges




                      6993 silver badges8 bronze badges







                      • 6





                        Sounds like an overkill here.

                        – Michael Krelin - hacker
                        Aug 26 '09 at 21:20






                      • 1





                        Yeah, probably...just a suggestion if someone wants to get more fancy in the future ;)

                        – KFro
                        Aug 26 '09 at 21:23






                      • 3





                        Yeah... there could be a game of PONG going on while we wait for the progress bar. :D

                        – kjfletch
                        Aug 26 '09 at 21:30











                      • thanks for the tip ;) I know about ncurses, I've used it before to make a terminal hangman game, but I wanted to ask around before using it cause I knew it was overkill

                        – ldog
                        Aug 26 '09 at 21:33












                      • 6





                        Sounds like an overkill here.

                        – Michael Krelin - hacker
                        Aug 26 '09 at 21:20






                      • 1





                        Yeah, probably...just a suggestion if someone wants to get more fancy in the future ;)

                        – KFro
                        Aug 26 '09 at 21:23






                      • 3





                        Yeah... there could be a game of PONG going on while we wait for the progress bar. :D

                        – kjfletch
                        Aug 26 '09 at 21:30











                      • thanks for the tip ;) I know about ncurses, I've used it before to make a terminal hangman game, but I wanted to ask around before using it cause I knew it was overkill

                        – ldog
                        Aug 26 '09 at 21:33







                      6




                      6





                      Sounds like an overkill here.

                      – Michael Krelin - hacker
                      Aug 26 '09 at 21:20





                      Sounds like an overkill here.

                      – Michael Krelin - hacker
                      Aug 26 '09 at 21:20




                      1




                      1





                      Yeah, probably...just a suggestion if someone wants to get more fancy in the future ;)

                      – KFro
                      Aug 26 '09 at 21:23





                      Yeah, probably...just a suggestion if someone wants to get more fancy in the future ;)

                      – KFro
                      Aug 26 '09 at 21:23




                      3




                      3





                      Yeah... there could be a game of PONG going on while we wait for the progress bar. :D

                      – kjfletch
                      Aug 26 '09 at 21:30





                      Yeah... there could be a game of PONG going on while we wait for the progress bar. :D

                      – kjfletch
                      Aug 26 '09 at 21:30













                      thanks for the tip ;) I know about ncurses, I've used it before to make a terminal hangman game, but I wanted to ask around before using it cause I knew it was overkill

                      – ldog
                      Aug 26 '09 at 21:33





                      thanks for the tip ;) I know about ncurses, I've used it before to make a terminal hangman game, but I wanted to ask around before using it cause I knew it was overkill

                      – ldog
                      Aug 26 '09 at 21:33











                      7














                      Something like this:



                      std::stringstream out;
                      for (int i = 0; i< 10; i++)

                      out << "X";
                      cout << "r" << "[" << out.str() << "]";



                      The sneaky bit is the carriage return character "r" which causes the cursor to move to the start of the line without going down to the next line.






                      share|improve this answer



























                        7














                        Something like this:



                        std::stringstream out;
                        for (int i = 0; i< 10; i++)

                        out << "X";
                        cout << "r" << "[" << out.str() << "]";



                        The sneaky bit is the carriage return character "r" which causes the cursor to move to the start of the line without going down to the next line.






                        share|improve this answer

























                          7












                          7








                          7







                          Something like this:



                          std::stringstream out;
                          for (int i = 0; i< 10; i++)

                          out << "X";
                          cout << "r" << "[" << out.str() << "]";



                          The sneaky bit is the carriage return character "r" which causes the cursor to move to the start of the line without going down to the next line.






                          share|improve this answer













                          Something like this:



                          std::stringstream out;
                          for (int i = 0; i< 10; i++)

                          out << "X";
                          cout << "r" << "[" << out.str() << "]";



                          The sneaky bit is the carriage return character "r" which causes the cursor to move to the start of the line without going down to the next line.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Aug 26 '09 at 21:19









                          1800 INFORMATION1800 INFORMATION

                          102k24 gold badges139 silver badges226 bronze badges




                          102k24 gold badges139 silver badges226 bronze badges





















                              3














                              Others have already pointed out that you can use r to go back to the beginning of the current line, and overwrite the entire line.



                              Another possibility is to use the backspace character ("b") to erase a few spaces, and overwrite only those spaces. This can have a couple of advantages. First, it obviously avoids having to regenerate everything in the line, which can sometimes be mildly painful (though that is fairly unusual). Second, it can avoid some pain in displaying data that (for one example) shrinks in size as you write it -- for example, if you're displaying a count-down from 100 to 0, with r you have to be careful about overwriting the entire previous length, or your countdown will go from (for example) 100 to 990 (i.e., leaving the previous "0" intact).



                              Note, however, that while back-space within a line normally works, a backspace at the beginning of a line may or may not move the cursor/write position back to a previous line. For most practical purposes, you can only move around within a single line.






                              share|improve this answer



























                                3














                                Others have already pointed out that you can use r to go back to the beginning of the current line, and overwrite the entire line.



                                Another possibility is to use the backspace character ("b") to erase a few spaces, and overwrite only those spaces. This can have a couple of advantages. First, it obviously avoids having to regenerate everything in the line, which can sometimes be mildly painful (though that is fairly unusual). Second, it can avoid some pain in displaying data that (for one example) shrinks in size as you write it -- for example, if you're displaying a count-down from 100 to 0, with r you have to be careful about overwriting the entire previous length, or your countdown will go from (for example) 100 to 990 (i.e., leaving the previous "0" intact).



                                Note, however, that while back-space within a line normally works, a backspace at the beginning of a line may or may not move the cursor/write position back to a previous line. For most practical purposes, you can only move around within a single line.






                                share|improve this answer

























                                  3












                                  3








                                  3







                                  Others have already pointed out that you can use r to go back to the beginning of the current line, and overwrite the entire line.



                                  Another possibility is to use the backspace character ("b") to erase a few spaces, and overwrite only those spaces. This can have a couple of advantages. First, it obviously avoids having to regenerate everything in the line, which can sometimes be mildly painful (though that is fairly unusual). Second, it can avoid some pain in displaying data that (for one example) shrinks in size as you write it -- for example, if you're displaying a count-down from 100 to 0, with r you have to be careful about overwriting the entire previous length, or your countdown will go from (for example) 100 to 990 (i.e., leaving the previous "0" intact).



                                  Note, however, that while back-space within a line normally works, a backspace at the beginning of a line may or may not move the cursor/write position back to a previous line. For most practical purposes, you can only move around within a single line.






                                  share|improve this answer













                                  Others have already pointed out that you can use r to go back to the beginning of the current line, and overwrite the entire line.



                                  Another possibility is to use the backspace character ("b") to erase a few spaces, and overwrite only those spaces. This can have a couple of advantages. First, it obviously avoids having to regenerate everything in the line, which can sometimes be mildly painful (though that is fairly unusual). Second, it can avoid some pain in displaying data that (for one example) shrinks in size as you write it -- for example, if you're displaying a count-down from 100 to 0, with r you have to be careful about overwriting the entire previous length, or your countdown will go from (for example) 100 to 990 (i.e., leaving the previous "0" intact).



                                  Note, however, that while back-space within a line normally works, a backspace at the beginning of a line may or may not move the cursor/write position back to a previous line. For most practical purposes, you can only move around within a single line.







                                  share|improve this answer












                                  share|improve this answer



                                  share|improve this answer










                                  answered Jun 11 '12 at 15:57









                                  Jerry CoffinJerry Coffin

                                  395k57 gold badges490 silver badges933 bronze badges




                                  395k57 gold badges490 silver badges933 bronze badges





















                                      1














                                      'r' will perform a carriage return. Imagine a printer doing a carriage return without a linefeed ('n'). This will return the writing point back to the start of the line... then reprint your updated status on top of the original line.






                                      share|improve this answer



























                                        1














                                        'r' will perform a carriage return. Imagine a printer doing a carriage return without a linefeed ('n'). This will return the writing point back to the start of the line... then reprint your updated status on top of the original line.






                                        share|improve this answer

























                                          1












                                          1








                                          1







                                          'r' will perform a carriage return. Imagine a printer doing a carriage return without a linefeed ('n'). This will return the writing point back to the start of the line... then reprint your updated status on top of the original line.






                                          share|improve this answer













                                          'r' will perform a carriage return. Imagine a printer doing a carriage return without a linefeed ('n'). This will return the writing point back to the start of the line... then reprint your updated status on top of the original line.







                                          share|improve this answer












                                          share|improve this answer



                                          share|improve this answer










                                          answered Aug 26 '09 at 21:20









                                          kjfletchkjfletch

                                          4,3631 gold badge27 silver badges33 bronze badges




                                          4,3631 gold badge27 silver badges33 bronze badges





















                                              1














                                              It's a different language, but this question might be of assistance to you. Basically, the escape character r (carriage Return, as opposed to n Newline) moves you back to the beginning of your current printed line so you can overwrite what you've already printed.






                                              share|improve this answer





























                                                1














                                                It's a different language, but this question might be of assistance to you. Basically, the escape character r (carriage Return, as opposed to n Newline) moves you back to the beginning of your current printed line so you can overwrite what you've already printed.






                                                share|improve this answer



























                                                  1












                                                  1








                                                  1







                                                  It's a different language, but this question might be of assistance to you. Basically, the escape character r (carriage Return, as opposed to n Newline) moves you back to the beginning of your current printed line so you can overwrite what you've already printed.






                                                  share|improve this answer















                                                  It's a different language, but this question might be of assistance to you. Basically, the escape character r (carriage Return, as opposed to n Newline) moves you back to the beginning of your current printed line so you can overwrite what you've already printed.







                                                  share|improve this answer














                                                  share|improve this answer



                                                  share|improve this answer








                                                  edited May 23 '17 at 12:32









                                                  Community

                                                  11 silver badge




                                                  11 silver badge










                                                  answered Aug 26 '09 at 21:20









                                                  TimTim

                                                  52.9k16 gold badges145 silver badges154 bronze badges




                                                  52.9k16 gold badges145 silver badges154 bronze badges





















                                                      1














                                                      Another option is to simply print one character at a time. Typically, stdout is line buffered, so you'll need to call fflush(stdout) --



                                                      for(int i = 0; i < 50; ++i) 
                                                      putchar('X'); fflush(stdout);
                                                      /* do some stuff here */

                                                      putchar('n');


                                                      But this doesn't have the nice terminating "]" that indicates completion.






                                                      share|improve this answer



























                                                        1














                                                        Another option is to simply print one character at a time. Typically, stdout is line buffered, so you'll need to call fflush(stdout) --



                                                        for(int i = 0; i < 50; ++i) 
                                                        putchar('X'); fflush(stdout);
                                                        /* do some stuff here */

                                                        putchar('n');


                                                        But this doesn't have the nice terminating "]" that indicates completion.






                                                        share|improve this answer

























                                                          1












                                                          1








                                                          1







                                                          Another option is to simply print one character at a time. Typically, stdout is line buffered, so you'll need to call fflush(stdout) --



                                                          for(int i = 0; i < 50; ++i) 
                                                          putchar('X'); fflush(stdout);
                                                          /* do some stuff here */

                                                          putchar('n');


                                                          But this doesn't have the nice terminating "]" that indicates completion.






                                                          share|improve this answer













                                                          Another option is to simply print one character at a time. Typically, stdout is line buffered, so you'll need to call fflush(stdout) --



                                                          for(int i = 0; i < 50; ++i) 
                                                          putchar('X'); fflush(stdout);
                                                          /* do some stuff here */

                                                          putchar('n');


                                                          But this doesn't have the nice terminating "]" that indicates completion.







                                                          share|improve this answer












                                                          share|improve this answer



                                                          share|improve this answer










                                                          answered Aug 26 '09 at 22:30









                                                          NVRAMNVRAM

                                                          4,5787 gold badges34 silver badges43 bronze badges




                                                          4,5787 gold badges34 silver badges43 bronze badges





















                                                              0














                                                              I've written this loading bar utility some time ago. Might be useful...



                                                              https://github.com/BlaDrzz/CppUtility/tree/master/LoadingBar



                                                              You can customise basically anything in here.



                                                              int max = 1000;
                                                              LoadingBar* lb = new LoadingBar(10, 0, max);

                                                              for (size_t i = 0; i <= max; i++)

                                                              lb->print();
                                                              lb->iterate();

                                                              cout << lb->toString() << endl;


                                                              Very simple and customisable implementation..






                                                              share|improve this answer



























                                                                0














                                                                I've written this loading bar utility some time ago. Might be useful...



                                                                https://github.com/BlaDrzz/CppUtility/tree/master/LoadingBar



                                                                You can customise basically anything in here.



                                                                int max = 1000;
                                                                LoadingBar* lb = new LoadingBar(10, 0, max);

                                                                for (size_t i = 0; i <= max; i++)

                                                                lb->print();
                                                                lb->iterate();

                                                                cout << lb->toString() << endl;


                                                                Very simple and customisable implementation..






                                                                share|improve this answer

























                                                                  0












                                                                  0








                                                                  0







                                                                  I've written this loading bar utility some time ago. Might be useful...



                                                                  https://github.com/BlaDrzz/CppUtility/tree/master/LoadingBar



                                                                  You can customise basically anything in here.



                                                                  int max = 1000;
                                                                  LoadingBar* lb = new LoadingBar(10, 0, max);

                                                                  for (size_t i = 0; i <= max; i++)

                                                                  lb->print();
                                                                  lb->iterate();

                                                                  cout << lb->toString() << endl;


                                                                  Very simple and customisable implementation..






                                                                  share|improve this answer













                                                                  I've written this loading bar utility some time ago. Might be useful...



                                                                  https://github.com/BlaDrzz/CppUtility/tree/master/LoadingBar



                                                                  You can customise basically anything in here.



                                                                  int max = 1000;
                                                                  LoadingBar* lb = new LoadingBar(10, 0, max);

                                                                  for (size_t i = 0; i <= max; i++)

                                                                  lb->print();
                                                                  lb->iterate();

                                                                  cout << lb->toString() << endl;


                                                                  Very simple and customisable implementation..







                                                                  share|improve this answer












                                                                  share|improve this answer



                                                                  share|improve this answer










                                                                  answered May 24 '18 at 12:38









                                                                  BlaDrzzBlaDrzz

                                                                  53 bronze badges




                                                                  53 bronze badges



























                                                                      draft saved

                                                                      draft discarded
















































                                                                      Thanks for contributing an answer to Stack Overflow!


                                                                      • Please be sure to answer the question. Provide details and share your research!

                                                                      But avoid


                                                                      • Asking for help, clarification, or responding to other answers.

                                                                      • Making statements based on opinion; back them up with references or personal experience.

                                                                      To learn more, see our tips on writing great answers.




                                                                      draft saved


                                                                      draft discarded














                                                                      StackExchange.ready(
                                                                      function ()
                                                                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f1337529%2fhow-to-update-a-printed-message-in-terminal-without-reprinting%23new-answer', 'question_page');

                                                                      );

                                                                      Post as a guest















                                                                      Required, but never shown





















































                                                                      Required, but never shown














                                                                      Required, but never shown












                                                                      Required, but never shown







                                                                      Required, but never shown

































                                                                      Required, but never shown














                                                                      Required, but never shown












                                                                      Required, but never shown







                                                                      Required, but never shown







                                                                      Popular posts from this blog

                                                                      Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                                                                      SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                                                                      은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현