Comments should be used in program code to document the program. This is to explain the neat but esoteric aspects of the program, not only to the programmer himself, but to any successors who find themselves needing to understand the code. Good comments don't repeat the code, they explain it; comments may tell why something is being done, or why it is being done this way. They may summarize the effect of a subprogram. A compiler treats the comment as if it were a single blank space.
The C language supports block comments.
Comments should be used in program code to document the program. This is to explain the neat but esoteric aspects of the program, not only to the programmer himself, but to any successors who find themselves needing to understand the code. Good comments don't repeat the code, they explain it; comments may tell why something is being done, or why it is being done this way. They may summarize the effect of a subprogram. A compiler treats the content of a comment as if it were not there.
Syntactically, C treats comments as token separators or "white space." Comments are otherwise ignored by the compiler.
Comments can span lines.
/* Comments can be on a single line */
/*
Comments can also
span multiple lines.
*/
x = 4; /* Comments should explain the code, not repeat it. */
| Compaq | Compaq C Language Reference Manual | |
| MSDN | C Comments | Visual Studio 6.0 |
| Dennie Van Tassel | Comments |
|
C Now
| C Comments |
| C++ Now | C++ Comments |
| C# Now | C# Comments |
| COBOL Now | COBOL Comments |
| FORTRAN Now | FORTRAN Comments |
| Java Now | Java Comments |
| JavaScript Now | JavaScript Comments |
| Pascal Now | Pascal Comments |
| Perl Now | Perl Comments |
| PHP Now | PHP Comments |