주석은 컴파일러에서 무시되는 코드의 일부입니다. 코드를 읽고 이해하기 쉽게 만듭니다. 단일 및 여러 줄 주석은 모두 C++ 언어에서 동일한 방식으로 작동합니다.
C/C++의 주석
// Single Line Comment /* Multi Line Comments */
다음은 C 언어로 된 주석의 예입니다.
예시
#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);
} 출력
Length of string : 10
위의 프로그램에서는 단일 주석과 다중 행 주석이 모두 표시됩니다. 프로그램이 문자 집합을 대상으로 복사하고 있습니다.
/* 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