Previous: 2.2 Organization of C Programs - Simple Statements
Up: 2.2 Organization of C Programs - Simple Statements
Next: Defining a Function --- main()
Previous Page: 2.2 Organization of C Programs - Simple Statements
Next Page: Defining a Function --- main()

2.2.1 Comment Statements

As already mentioned, the text contained within /* and */ is called a comment. When the character pair /* is encountered, all subsequent text is ignored until the next */ is encountered. Comments are not part of the program; they are private notes that the programmer makes about the program to help one understand the logic. Comments may appear anywhere in a program but cannot contain other comments, i.e., they cannot be nested. For example:

/* This is a comment. /* Nested comments are not allowed */ this part
     is not in a comment. */
The comment starts with the first /*. When the first matching */ is encountered after the word allowed, the comment is ended. The remaining text is not within the comment and the compiler tries to interpret the remaining text as program statement(s), most likely leading to errors.

tep@wiliki.eng.hawaii.edu
Tue Aug 16 14:01:55 HST 1994