728x90
반응형
bool
- true, false를 표현하는 타입
- 보통은 1byte
더보기
# include <iostream>
using namespace std;
int main()
{
bool b0 = 0 == 0; // true
bool b1 = 0 < 1; // true
bool b2 = 0 > 1; // false
// 1 or 0으로 출력
cout << "b0 : " << b0 << endl;
cout << "b1 : " << b1 << endl;
cout << "b2 : " << b2 << endl;
// ture flase로 출력하기
cout.setf(ios_base::boolalpha);
cout << "b0 : " << b0 << endl;
cout << "b1 : " << b1 << endl;
cout << "b2 : " << b2 << endl;
// bool형은 조건식에서 많이 사용된다. 꼭 알아두기
// 0은 거짓이지만 0이 아니면 모두 ture다 -1도 ture
}
728x90
반응형
최근댓글