Home>Article>Backend Development> How to annotate C language programs?

How to annotate C language programs?

尚
Original
2020-04-17 13:44:34 9999browse

How to annotate C language programs?

When writing C language source code, you should use more comments to help understand the code. There are two comment methods in C language:

One is a block comment starting with /* and ending with */;

The other is starting with // , a single-line comment ending with a newline character (line comment).

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 and the comments in the right column:

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

Recommended: "c Language Tutorial"

The above is the detailed content of How to annotate C language programs?. 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