Type of Comments
In C programming language we have two type of comments.
- Single Line Comment
- Multi Line Comment
1. Single Line Comment:
- Single line comments are used to hide single line of code or text from compiler.
- Single-line comments start with two forward slashes (//).
- Any text after // will be ignored by the c compiler
Syntex:
printf("Hello World!");
printf("Any Message!");
2. Multi Line Comment:
- Multi-line comments are used to hide group or block of text from compiler.
- Multi-line comments start with /* and ends with */ in c language.
- Any text between /* and */ will be ignored by the c compiler
Syntex:
printf("Message!");
should i use single line comment or multiline comment?
It's up to developer which one he wants to use. Normally, we use // for short comments, and /* */ for longer one.
Few things that must remember while writing comments in C programing: