Simple implementation of the progress bar under Linux

Source: Internet
Author: User
Tags sleep function

  Before you implement the progress bar, learn the makefile first.

There are countless source files in a project, which are placed in several directories by type, function and module, and makefile defines a series of rules to specify which files need to be compiled first, which files need to be compiled, which files need to be recompiled, and even more complex functional operations. Make is a command tool that is a command tool that interprets instructions in makefile.

Beginners can only implement the following lines of simple code.

  

  Use of MAKE commands

  

  Take a look at the progress bar.

Principle: Each output of the character is more than the last character of the output of one, through the sleep function to control how often output once, and do not use a newline, only use the carriage return.

Note: 1. The difference between a carriage return and a newline

Before the computer appeared, there was a gadget called a telex typewriter (teletype Model 33) that could play 10 characters per second. But it has a problem, that is, when the line is finished, it will take 0.2 seconds to hit two characters. If there are new characters coming in this 0.2 seconds, then this character will be lost. So, the developers think of a way to solve this problem, is to add two after each line to end the character. One is called "carriage return", which tells the typewriter to position the printhead at the left border, and the other is called "line break", telling the typewriter to move the paper down one line. This is the origin of "line break" and "carriage return".

So

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

\ n Wrap: Make the cursor to the next line

The output at 2.linux is cached, and if the display is refreshed in a timely manner, the Fflush function needs to be called.

  

 :

  

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.