C Language Play Letter Small program Implementation----notes Little note

Source: Internet
Author: User
Tags clear screen sleep function

1, develop good programming habits. For example: definition of Function name, definition of variable name and so on.


2, the use of modular ideas to design and write program code.

For example, for a program segment that implements a feature, it should be designed as a function function and then called directly where the main function is needed, thus reducing the amount of code in the main function and improving the readability of the code.


3, for the smart use of the loop, the loop output format control.

Example: Looping out line breaks or spaces

for (int i = 0;i < num;i++) {printf ("\ r \ n");//Loop output newline//or printf ("");//Loop Output spaces}

4. Use of the Sleep function

Implementation function: Execution suspend for a period of time function form: void Sleep (unsigned long); Header file: #include <windows.h>//Note: The Unit in sleep () is measured in milliseconds, so if you want the function to be stuck for 1 seconds, it should be sleep (1000);


5, C language, the control output of the line.

printf ("\ r \ n"), commonly used in Windows systems Programming: line-wrapping output, printf ("\ n"), is commonly used in Linux system programming: NewLine output.


6, Smart use of tabs, to achieve the corresponding functions.

For example, use \b tabs. Output a fallback key (that is, equivalent to pressing a backspace key on the keyboard that is the fallback key) printf ("\b");

7, C + + program, often call the system function, to implement the DOS window interface related operations.

For example, System ("CLS");/* Clear screen operation */

8. Use of the Exit function

Function: Closes all files and terminates the process being executed. In C + +, the usual form: exit (0);/* indicates normal exit, end program */equivalent to return 0;exit (1),/* indicates abnormal exit, end program */equivalent to return 1;


This article is from the "Memory Route" blog, be sure to keep this source http://zhanglives.blog.51cto.com/8762788/1856251

C Language Play Letter Small program Implementation----notes Little note

Related Article

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.