English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

C / C ++Comments in

Comments are part of the code, and the compiler ignores them. They make the code easy to read and understand. Single-line comments and multi-line comments in C ++work in the same way in the language.

C / C ++Comments in

// Single-line Comment
/*
Multi-line Comments
*/

This is an example of C language comments,

Example

#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 Result

Length of string: 10

In the above program, both single-line and multi-line comments are displayed. The program is copying the character set to the target location.

/* 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