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