Comment Pairs Do Not Nest
A comment that begins with /* ends with the next */. As a result, one comment pair cannot appear inside another. The compiler error messages that result from this kind of mistake can be mysterious and confusing. As an example, compile the following program on your system:
-
- cannot nest.
- * ‘‘cannot nest’’ is considered source code,
- * as is the rest of the program
- */
- int main()
- {
- return 0;
- }
We often need to comment out a block of code during debugging. Because that code might contain nested comment pairs, the best way to comment a block of code is to insert single-line comments at the beginning of each line in the section we want to ignore:
-
-
-
-