Comments
/*Displaying a Quotation */ #include <stdio.h> int main(void) { printf("hi from book2s.com!"); return 0; }
Look at the first line of code in the preceding example:
/*Displaying a Quotation */
This isn't actually part of the program code.
It's simply a comment, and it's there to remind you, or someone else reading your code, what the program does.
Anything between /* and */ is treated as a comment.
This may be on the same line or it can be several lines further on.
Here's how you could use a single comment to identify the author of the code and to assert your copyright:
/*
* Written by book2s.com
* Copyright 2019
*/
You can also embellish comments to make them stand out:
/*******************************************
* This is a very important comment *
* so please read this. *
*******************************************/
You can add a comment at the end of a line of code using a different notation, like this:
printf("hi from book2s.com!"); // This line displays a quotation Everything following two forward slashes on a line is ignored by the compiler.
Let's add some more comments to the program:
/* Displaying a Quotation */ #include <stdio.h> // This is a preprocessor directive int main(void) // This identifies the function main() { // This marks the beginning of main() printf("hi from book2s.com!"); // This line outputs a quotation return 0; // This returns control to the operating system } // This marks the end of main()