C - Comments

Comments explain code and are ignored by the compiler.

Types

  • Line comment: // comment to end of line
  • Block comment: /* spans multiple lines */

Examples

// compute sum
int sum = a + b; /* add two ints */

/*
 Multi-line description
 of an algorithm
*/

Common Pitfalls

  • Nested /* block /* comments */ not allowed in standard C.
  • Accidentally commenting out closing braces or code blocks.