주석 (프로그래밍)

위키백과, 우리 모두의 백과사전.

주석 또는 코멘트(comment)는 프로그래밍에 있어 내용을 메모하는 목적으로 쓰인다.

소스 코드를 더 쉽게 이해할 수 있게 만드는 것이 주 목적이며, 협업할 때 유용히 쓰인다. # 이후 줄의 끝까지는 컴파일러인터프리터에 의해 일반적으로 무시되어 프로그램에 영향을 주지 않는다.[1][2]

언어 별 주석의 형태[편집]

C, C++, C 샤프, 자바, 자바 스크립트[편집]

C, C++, C 샤프, 자바, 자바 스크립트의 경우에 한 줄 주석은 //, 여러 줄 주석은 /* */이다.

예제

대표적으로 C에서는 아래와 같이 사용된다.

/* Hello World라는 문구를 출력 시켜주는
프로그램이다. */
#include <stdio.h>
main()
{
    printf("Hello World \n"); //Hello World라는 문구를 출력한다.
}

어셈블리어[편집]

어셈블리어에서 주석은 ;이다.

HTML[편집]

HTML의 경우에 주석은 <!-- -->이다.

예제
<!DOCTYPE HTML>
<HTML>
<HEAD>
<TITLE>주석</TITLE>
</HEAD>
<BODY>
<!-- 주석 -->
주석
</BODY>
</HTML>

파이썬[편집]

파이썬의 경우에 한줄 주석은 #, 여러줄 주석은 ''' ''',""" """이다.

예제

'''Hello World! 라는 문구를
    출력시켜주는 프로그램이다.'''

print("Hello World!") #출력

각주[편집]

  1. Source code can be divided into program code (which consists of machine-translatable instructions); and comments (which include human-readable notes and other kinds of annotations in support of the program code).Penny Grubb, Armstrong Takang (2003). 《Software Maintenance: Concepts and Practice》. World Scientific. 7, 120–121쪽. ISBN 981-238-426-X. 
  2. For purposes of this article, programming language comments are treated as indistinct from comments that appear in markup languages, configuration files and other similar contexts. Moreover, markup language is often closely integrated with programming language code, especially in the context of code generation. See e.g., Ganguli, Madhushree (2002). 《Making Use of Jsp》. New York: Wiley. ISBN 0-471-21974-6. , Hewitt, Eben (2003). 《Java for Coldfusion Developers》. Upper Saddle River: Pearson Education. ISBN 0-13-046180-6.