From the course: Complete Guide to C Programming Foundations

Unlock the full course today

Join today to access over 24,300 courses taught by industry experts.

Adding comments

Adding comments

- [Instructor] Comments are used for a variety of purposes. They can provide information, documentation, and are used in debugging. In the big picture, a comment is a part of your source code that the compiler ignores. It skips over all the commented text. The C language uses two styles of comment. The traditional C language comment starts with the /* characters, and ends with the */ character. All text between these character pairs is ignored by the compiler. The C++ style comment starts with //. All text after the two slashes is ignored until the end of the line. This code shows both style of comments. Lines 1 through 3 are a comment block using the traditional C language start and stop comment characters. Line 4 contains a C++ style comment at the end of the line. Line 9 has a comment at the end of the line as well, but it's enclosed in traditional C style comment characters. One of the purposes of comments is to document your code. The idea is to explain what you're doing to a…

Contents