Home >Backend Development >C#.Net Tutorial >There are several annotation methods in C language

There are several annotation methods in C language

王林
王林Original
2020-07-01 10:19:1614600browse

C language has two comment methods, one is a block comment starting with /* and ending with */; the other is a single-line comment starting with // and ending with a newline character. The specific usage is as follows: [const double pi = 3.1415926536; // pi is a constant].

There are several annotation methods in C language

When writing C language source code, you should use more comments to help understand the code.

(Recommended learning: C Language Tutorial)

There are two comment methods in C language:

  • One It is a block comment that starts with /* and ends with */;

  • The other is a single-line comment that starts with // and ends with a newline character (line comment) .

Example:

You can use /* and */ delimiters to mark comments within one line, or to mark comments on multiple lines.

For example, in the following function prototype, the ellipsis means that the open() function has a third parameter, which is optional.

The comment explains the usage of this optional parameter:

int open( const char *name, int mode, … /* int permissions */ );

You can use // to insert a whole line of comments, or write the source code in a two-column format, with the program in the left column, Note in the right column:

const double pi = 3.1415926536;  // pi是—个常量

The above is the detailed content of There are several annotation methods in C language. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn