Adding Comments to Your Source Code

Although they do nothing for the functionality of an application, comments are still a critical part of any programming language. Comments are necessary to remind yourself—while you're initially developing an application or when you come back months later—why you did certain things. These are some of the most common uses for comments:

  • Indicate the purpose of a file

  • Document who created a file and when

  • Note the thinking behind a function

  • Clearly state the meaning of variables

  • Explain why particular numbers are used

  • Mark contingencies or assumptions being made

C supports two comment formats. The first allows you to write comments over multiple lines:

/* Multiline comments
have start and end delineators. */

Some ...

Get C Programming: Visual Quickstart Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.