"Learning Notes", "C language" comments

Source: Internet
Author: User

1. What is a comment

1) Annotations are a concept that is very important in all computer languages, literally, the meaning of annotations and explanations.

2) Comments can be used to explain the meaning of a program or a line of code to facilitate communication between programmers. If I finish writing a line of code and add the corresponding comment, then people will see this comment and know what my line of code is for.

3) Comments can be any text, which means you can write Chinese

4) Note in development tools is generally red bean paste Green

2. Single-line Comment

1) The single-line comment starts with two forward slashes, that is, starts with//, can only comment one line, from//start to the end of this line is the contents of the comment

2) anywhere you can write a comment: Outside the function, inside, behind each statement

3. Multi-line annotations

Multiline comments start with/*, end with */, the contents of/* and/* are commented

4. The role of annotations

1> Annotated code does not participate in compilation

* Comments are written to people, not to the computer. How can a computer see the Chinese we write? Therefore, when compiling the program, the comments are not compiled into the. O Destination file

* From the size of the. o file you can see indirectly that the code after the comment is not compiled

2> checking the role of code

3> Troubleshooting Errors

5. Nested behavior of annotations

1) Single-line comments can be nested single-line comments, multiline comments

Single line 1//single line 2

/* DSSF *//Dssfblog

2) multiline annotations can nest single-line comments

This is still a comment
*/

3) Multiline comments cannot nest multiple lines of comments

/* 12345
/* Hit the Tiger on the hill * *
The tiger is not at home *

4) The following wording is wrong

This side is not commented, should be///be commented out
*/
6. Importance of annotations
L, to develop a good habit of writing notes. Most project managers check the subordinate code of the first thing is to see if there is no comment, there are many companies will also check the machine test comments (the test is to give you a programming problem, a computer, in the specified time to solve problems)
2, today, you write hundreds of lines of code, very happy, made a very good function, but, forget to write comments. After one weeks, it's normal for you to go back and look at that piece of code, which you may not be able to understand at all. If you write a comment, the situation is different, and comments can help you review the role of the Code.
3, you have been in a company for more than 1 years, wrote 10 tens of thousands of lines of code, but you do not write a little comment. One day you quit and the new employee takes over your project, the first thing he must do is to read the code you wrote. But you did not write a little note, 100,000 lines of code, all in English, which will make the new employee very egg pain. Everyone has their own ideas, the idea of writing code is certainly not the same, it is very painful to see the code written by others, especially the code without comments. The way you do not write comments can greatly reduce your company's development efficiency. As a result, all formal companies attach great importance to annotations.

"Learning Notes", "C language" comments

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.