Simple implementation of the progress bar under Linux

Source: Internet
Author: User

The topic of this article is to implement a progress bar, the application of the progress bar in the software everywhere, copy a file requires a progress bar, loading a file also need a progress bar, to mark the completion or not.

So, what are the elements of a progress bar:

1. A container that keeps growing to the right (intuitively seeing the current progress)

2. A data-reflecting percentage of progress.

3. A sign that indicates whether the progress bar is working or is stuck

But some places still need to be noticed.

1. The first is the carriage return, the carriage return is not \ n, we can think of \ n as a combination of two actions, the carriage return and line change, each has its own corresponding symbol, which uses the carriage return has been in the same position output caused by the illusion of dynamic

2. Because there is no use of \ n and newline, but the C language printf is the row buffer output, what does it mean? That is, the dissatisfaction line does not output, is to rely on \ n output, not \ n forced to buffer the data out of the output so this will be used to function fflush ().

   \ r Enter: Causes the cursor to return to the beginning of this line

\ n Wrap: Make the cursor to the next line

Program source Code

Simple implementation of the progress bar under Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.