Comments in C/C++

CC++Server Side Programming

Comments are the part of code which are ignored by the compiler. It makes the code easy to read and understand. Single and multi-line comments both work in the same way in C++ language.

Comments in C/C++

// Single Line Comment

/*
Multi Line Comments
*/

Here is an example of comments in C language,

Example

 Live Demo

#include <stdio.h>
#include <string.h>
int main () {
   /* declarations
   of
   data members */
   char s[10] = "HelloWorld";
   char d[10];
   int n;
   n = strxfrm(d, s, 5);
   printf("Length of string : %d", n); // length of string
   return(0);
}

Output

Length of string : 10

In the above program, both comments single and multi-line are displayed. The program is copying the set of characters to the destination.

/* declarations
of
data members */
char s[10] = "HelloWorld";
char d[10];
int n;
n = strxfrm(d, s, 5);
printf("Length of string : %d", n); // length of string
raja
Published on 05-Nov-2018 14:56:07
Advertisements