3.13 불리언형

공기훈·2021년 7월 21일
0

홍정모의 따배씨

목록 보기
3/49

Boolean

#include <stdio.h>
#include <stdbool.h> 

int main()
{
	printf("%u\n", sizeof(_Bool)); // 1 byte  byte가 주소를 배정받을 수 있는 최소 단위

	_Bool b1; 
	b1 = 0; // false
	b1 = 1; // true

	printf("%d\n", b1); // 문자 형식이 따로 없어서 정수형처럼 사용 가능

	// <stdbool.h> include 하면 bool 사용 가능

	bool b2, b3;
	b2 = true; 
	b3 = false; // 컴퓨터는 false가 아니면 true다.. 라고 판단

	printf("%d%d\n", b2, b3); //1 0 출력

	return 0;
}
profile
be a coding master

0개의 댓글