C Language Beginner Programming specification 10 article

Source: Internet
Author: User

engaged in C language teaching also has a short time, in the teaching found that students in the programming has a very bad habit, is the arbitrary name, which not only to their own future reading procedures to bring inconvenience, but also to other programs to read the reader to bring trouble, more importantly, there is no uniform norms always appear to be a guerrilla, Without the feeling of the regular army, the enterprise is not willing to want amateurs, so C beginners better start to cultivate a good programming habit, maybe later into the company some changes, need to adapt, but the basic norms and rules are not needed to change, so that can help you to take a lot of detours, after these years of study and work, Summed up some of the specifications of the content, in order to good remember, easy to spread, special summary of 10, recommended that readers adopt.

First: the name of the identifier should be clear, clear, and have a definite meaning, while using the complete word or the basic understanding of the abbreviation, to avoid misleading people. The English words in the program are generally not too complicated and the words should be accurate. For example, do not write currentvalue nowvalue.

  < Span lang= "en-us" xml:lang= "en-US" > second: value1,value2 , etc., unless the number is logically required.

 

  third: printname (), oldname etc.

 

  fourth:   Programs use only const constants without using macro constants, which is const constants completely supersede macro constants. The constants are defined in uppercase letters k , with all uppercase letters, such as: const int ksize = + .

 

  fifth: code indentation using 4 spaces, not recommended tab key

Sixth: Copyright and version declarations are at the beginning of the file; The function header should be commented, listing functions, input parameters, output parameters, return values, and so on. The key code comment is located above the commented code and is separated by a blank line from other code, such as:

File Header Comment:


AUTHOR:SDL Team

Function:testing Hardware Drivers and IDE

date:2009.10

Copy right:software College of Hebei Normal University

Function Comment:


FUNCTION:SDL Initial

Parameter:none

Return:bool

True:initial SDL Normally

False:initial SDL abnormally

Key code Comments:

Ptemp = Sdl_loadbmp (afilename);

Format BMP File

*aimg = Sdl_displayformat (ptemp);

Sdl_freesurface (ptemp);

Seventh: static variables are prefixed with s_, such as:static int s_count = 0;

  eighth: try to avoid applying global variables, and if special cases must be defined, the global variable is lowercase Span lang= "en-us" xml:lang= "en-US" >g_ , such as: int  g_count = 0;

nineth: the first letter of the structure should be capitalized. such as:

struct Student

{

};

Tenth: enumeration and its members should be defined in a meaningful way to avoid ambiguity; the name of the enumeration variable begins with T , and the enumeration member begins with E .


This article is from the "8403723" blog, please be sure to keep this source http://8413723.blog.51cto.com/8403723/1662105

C Language Beginner Programming specification 10 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.