👩💻 C
C언어 - 참, 거짓 (bool , True , False) , <stdbool.h>
Newmon
2020. 10. 18. 18:01
*<stdbool.h>
C에서는 참과 거짓을 0과 0이 아닌 다른 숫자를 통해 표현한다. (0은 거짓, 그리고 그 외의 모든숫자는 참)
이때 stdbool.h 헤더파일을 사용하면 True, False를 사용 할 수있다.그리고 bool이라는 데이터타입도 사용 가능하다.
#include <stdio.h>
#include <stdbool.h> // bool, true, false가 정의된 헤더 파일
int main()
{
bool b1 = true;
if (b1 == true)
printf("참트루\n");
else
printf("False\n");
return 0;
}
이때 bool의 size는 1byte이다.