- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Comments in C/C++
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
#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
- Related Articles
- Comments in C#
- Comments in C++ Programming Language
- What are the comments in C#?
- Remove comments in a string using C++
- How to write multi-line comments in C#?
- How to write single-line comments in C#?
- What type of comments does C++ support?
- Comments in Java
- Comments in Perl
- Comments in Python
- Explain Comments in JavaScript
- Executable Comments in Java
- /** and /* in Java comments
- Comments in Dart Programming
- Comments in Rust Programming

Advertisements