C uses two types of comment: single-line and multi-line. The multi-line comment originated in C while the single-line comment originated in C++. Both types are supported by both languages today.
A single-line comment begins with the double-slash token (//) and extends to the end of the line.
A multi-line comment begins with the slash-asterisk token (/*) and ends with the asterisk-slash token (*/).
Examples:
int x; // this is a single-line comment
/* this is multi-line comment, typically
used to introduce a function or class */
Note that since multi-line comments are fully-delimited, they may be used within the middle of a line of code. This is most useful when a function is forward-declared with a default value for one of its arguments and you wish to include that default value in the function definition (something which is not permitted under the one-definition rule):
void f (int = 0); // declaration
void f (int x /* = 0 */) { // definition
}
Such usage is really only of use to the function maintainer, as a reminder that the function has a default value.
We can also use this technique when a function has an argument that is reserved for future use, but is otherwise unused in the current version of the function:
void g (int); // declaration
void g (int /* unused */) { // definition
}
Again, such usage is only of use to the function maintainer.
Copyright © 2026 eLLeNow.com All Rights Reserved.