Multi Line Comment : C Programming



Multi Line Comment

  • Multi Line Comment Can be Placed Anywhere.
  • Multi Line Comment Starts with ‘/*’ .
  • Multi Line Comment Ends with ‘*/’ .
  • Any Symbols written between ‘/*’ and ‘*/’ are ignored by Compiler.
  • It can be split over multiple Lines

Example :

#include<stdio.h>
void main()
{
printf("Hello");
/* Multi
       Line
  Comment 
*/
printf("By");
}

Which Part is Ignored by Compiler ? [Shown by Dash]

#include<stdio.h>
void main()
{
printf("Hello");
/*--------------------------------------------
  ------------------Ignored by compiler-------
  --------------------------------------------
*/
printf("By");
}

Different Ways of Using Multiple Line Comment :

Way 1 : Used for Program Title and Documentation

/****************************************
  * Title : Program Name *
  * Author: Author Name *
  ***************************************/

Way 2 : Used for More detailed comment inside program

/* following line is used to get -
          1.Count of the Customer 
          2.It is going to Return Integer
*/
int var = getCount(str);

OR

int var = getCount(str); /* Used to count 
                               Number of Persons
                                  Present */
pritnf("count : %d",var);