Page 79 - C-Language
P. 79
Chapter 10: Comments
Introduction
Comments are used to indicate something to the person reading the code. Comments are treated
like a blank by the compiler and do not change anything in the code's actual meaning. There are
two syntaxes used for comments in C, the original /* */ and the slightly newer //. Some
documentation systems use specially formatted comments to help produce the documentation for
code.
Syntax
• /*...*/
• //... (C99 and later only)
Examples
/* */ delimited comments
A comment starts with a forward slash followed immediately by an asterisk (/*), and ends as soon
as an asterisk immediately followed by a forward slash (*/) is encountered. Everything in between
these character combinations is a comment and is treated as a blank (basically ignored) by the
compiler.
/* this is a comment */
The comment above is a single line comment. Comments of this /* type can span multiple lines,
like so:
/* this is a
multi-line
comment */
Though it is not strictly necessary, a common style convention with multi-line comments is to put
leading spaces and asterisks on the lines subsequent to the first, and the /* and */ on new lines,
such that they all line up:
/*
* this is a
* multi-line
* comment
*/
The extra asterisks do not have any functional effect on the comment as none of them have a
related forward slash.
https://riptutorial.com/ 55

