C language entry: 03. keywords, identifiers, comments

Source: Internet
Author: User
Tags switch case

C language entry: 03. keywords, identifiers, comments
1. Note before learning the syntax (1) c language is a high-level language. In fact, the basic syntax components of all advanced languages are the same, but the expressions are not the same (2) just like the Asian and African people, everyone has a human structure: two hands, two feet, and one head, but they have different appearances, such as skin color and face shape (3, you have mastered a high-level language and want to learn other advanced languages. That's pretty fast (4) and many other advanced languages, such as Objective-C to be learned later, it is derived from the C language based on C language. Study the C language well and never suffer losses. 2. Keyword 1. what are keywords? (1) keywords are symbols with special meanings provided by the C language, also known as "Reserved Words" (2) a total of 32 keywords provided by the C language, these keywords are given special meanings by c language: auto double int struct break else long switch case enum register typedef char extern return union c Onst float short unsigned continue for signed void default goto sizeof volatile do if while static can be roughly browsed once without the use of each Baidu keyword. These keywords will be frequently used in the future, it's hard for you to remember. keyword features (1) are all lowercase (2) show special colors in development tools or smart text editing tools. By default, all keywords in C language are displayed in Xcode. which of the following are the keywords int, return, and identifier 1 in the main function. what is an identifier is some of the symbols and names customized in the program. To distinguish it from keywords: keywords are the default symbols provided by C language, and identifiers are customized by programmers. identifier (1) identifier, literally used to identify something, the purpose of the identifier is to distinguish these things (2) In fact, identifiers serve almost the same purpose as human names. In order to distinguish each person, a name is given at the time of birth. (3) c language is composed of functions, a c program may have multiple functions. to distinguish these functions, each function is given a name. The function name is a type of identifier. In addition to functions, we will also learn the concept of "variable". The variable name is also identifier 3. naming (1) Naming rules (must comply with) · only 26 English letters can contain uppercase and lowercase letters and 10 Arabic numerals 0 ~ 9. The combination of underscores (_) is case-sensitive. For example, test and Test are two different identifiers. They cannot start with a number. Keywords cannot be used as identifiers. (2) naming Conventions (preferably observed) give a meaningful name as much as possible, such as a complete English word. When someone else looks at the name, the identifier can be used. If you do not understand English, you can also use Pinyin. Do not use meaningless names such as abcde and sfsdfsdf. If the identifier contains multiple words, you can use the hump marker (except for the first word, the first letter of each word is capitalized): firstName, myFirstName, or use the underscore _ to connect: first_name, my_first_name 4. common identifier naming errors 5. exercise indicates the correctness of the identifier test1 Mike2jack My_tExt _ test! 32 haha (da) tt haha _ text 123 haha 78 text a _ 123 _ 4. Note 1. what is annotation (1) annotation is a very important concept in all computer languages. Literally, it refers to the meaning of annotation and interpretation (2) annotations can be used to explain the meaning of a program or a line of code to facilitate communication between programmers. If I add the corresponding comments after writing a line of code, then when others see this comment, they will know what the line of code is for (3) Comments can be any text, that is to say, you can write Chinese (4). the comment in the development tool is generally bean paste Green 2. single line comment (1) a single line comment starts with two forward slashes, and starts with //. Only one line can be commented. From // to the end of this line, all comments are comments. (2) comments can be written anywhere: 3. multi-line comment multi-line comment starts with/*, ends with */, and the content in the middle of */is comment 4. annotation function (1) the annotated code will not participate in compilation. Annotations are intended for users rather than computers. How Can computers view the Chinese we write. Therefore, when compiling a program, it does not compile the annotation. o from. o file size can be indirectly seen that the annotated code is not compiled (2) Check the role of the Code (3) Eliminate errors 5. nesting of comments (1) single-row comments can be nested with single-row comments and multiple-row comments // Haha // //* fsdfsdf * /// sdfsdfsd (2) multi-line comments can be nested with single-line comments/* // Author: MJ // Description: The first C language program function: This is a main function, the entry point of the C program */(3) multi-line comments cannot be nested multi-line comments/* hahaha/* */(4) The following statements are incorrect // * hahaha */6. the importance of comments should develop a good habit of writing comments. The first thing for most project managers to check their subordinate codes is to see if they have written comments. Many companies also try to check comments. (A computer test is to give you a programming question and a computer, today, you have written hundreds of lines of code and are very happy to have made a very good function. However, you forgot to write comments. After a week, you may not be able to understand the code. This is a normal task. If you write comments, the situation will be different. Comments can help you review the role of the Code. You have been in a company for more than a year and have written tens of thousands of lines of code, but you do not need to write any comments. One day, when you leave your job and a new employee takes over your project, he must first understand the code you wrote. However, you did not write any comments at all. The 0.1 million lines of code are all in English, which makes this new employee very painful. Everyone has their own ideas. The idea of writing code is definitely different. It is very painful to read the code written by others, especially the code without comments. If you do not write comments, the company's development efficiency will be greatly reduced. Therefore, all formal companies place great importance on annotations. 7. exercise to see if the following program can run successfully. If yes, run the result: (1) program 1 // main function int main () {printf ("itcast \ n "); return 0;} (2) Program 2 // main function int main () {printf ("// itcast \ n"); return 0 ;}( 3) program 3 main function int main () {printf ("itcast \ n"); return 0 ;}( 4) program 4 int main () {printf (// "itcast \ n"); return 0 ;}( 5) Program 5 int main () // main function {// printf ("itcast \ n"); return 0 ;}

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.