Write Comments in Source Code?
Source and header files do not have to include only source codes. You can also write comments, stories or paragraphs that describe what your code is about and will not be compiled by the compiler. A comment can start with double forward slashes (//
) or enclose with /*
and */
.
/* * myfuncs.c: * This is a comment block */ #include <stdio.h> #include <stdlib.h> void printHelloWorld(void) { // this is a line of comment printf("Hello World\n"); /* this is also a line of comment */ printf("Hello World Again!\n"); }
Do Not Forget the Semicolons
A semi colon is a special character that indicates the end of line. You must include it in every single line of source (except for preprocessor declarations). If you forget about it, you will get a compilation error.
/* * myfuncs.c */ #include <stdio.h> #include <stdlib.h> void promptAndPrint(void) { /* every line must end with semicolon ; */ int iNumber = 0; printf("Enter an integer please: "); /* you can put codes in one line as long as they are separated by semicolon ; */ scanf("%d", &iNumber); printf("You entered: %d", iNumber); printf("end of function"); }