C언어 integer constants, floating constants, character constants
조회수 617회
KNK C PROGRAMMING 2ND EDITION에 따르면 constants가 "constants- numbers that appear in the text of a program, not numbers that are read, written, or computed." 라고 정의되어 있는데 여기서 constants가 무엇을 의미하는 건가요? 그리고 integer constants, floating constants, character constants는 무슨 의미인지 가리켜 주시면 감사하겠습니다.
-
(•́ ✖ •̀)
알 수 없는 사용자
2 답변
-
constant는 상수를 나타내고요.
int a = 10; float b = 3.14f; char c = 'c';
예를 들어 위 코드에서
10
이 integer constant이고,3.14f
가 floating constant,'c'
가 character constant입니다.-
(•́ ✖ •̀)
알 수 없는 사용자
-
-
프로그래밍 언어 개념이 발달하면서 좀더 세밀하게 분류가 되었습니다.
책이 좀 오래되었거나, 단어 선택이 그렇게 적절치 못한 것 같습니다. 설명으로 뒤에 붙어있는 것을 보자면, 'literal value'를 constant 라고 서술하는 것 같습니다. 설명을 보자면 그렇죠.
그런데 일반적으로 constant 라고 말한다면, 프로그래밍 언어적인 개념에서 constant 인 것 같습니다. 변수에 대한 제약사항입니다. "해당 변수는 재할당할 수 없다."
https://stackoverflow.com/a/58033459/12365658
해당 글의 설명이 적절한 것 같습니다.
constant 는 프로그래밍 언어에서의 변수에 대해서 강제하는 제약사항. 이라고 이해하시면 될 것 같습니다.
정리하자면. 책에서 말하는 constant는 본 글에서의 literal value를 가리켜서 'constant'라고 단어로 나타내는 것 같은데, 현대에 있어서 그렇게 적절한 단어 선택은 아닌 것 같습니다.
댓글 입력