Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
Tags
- 이웃한 칸
- 개발
- Reflex
- 백준
- 프로그램
- frontend
- Python
- 프로그래밍
- 코딩
- 자바정리
- java정리
- 개발자
- java
- 자바독학
- C++
- 개인프로젝트
- backend
- 모의 주식
- 빅데이터
- 사물인터넷
- 코스닥
- SNS
- 코딩테스트
- 코딩독학
- 자바
- Project
- 풀스택프레임워크
- 코테
- 프로그래머스
- 주가예측
Archives
- Today
- Total
Creative Code
letterAttribute2.c (BOLD,ITALIC,SHADOW,UL) 본문
#include <stdio.h>
#define BOLD (0x01<<0) //0x01<<0
#define ITALIC (0x01 << 1) // 0x01 << 1
#define SHADOW (0x01 << 2) // 0x01 << 2
#define UL (0x01<<3) // 0x01 <<3, 시프트연산을 전처리해주려면 괄호를 써야한다 (안쓸 시 밑에 shadow+ italic에서 연산자 우선순위에 의해 계산이 꼬일 수 있음
int main(void)
{
unsigned char attr;
attr = attr ^ attr; // attr = 0; 결과는 attr = 0x00
attr = attr | BOLD; // 00000001 결과는 attr = 0x01
attr = attr | (SHADOW + ITALIC);// 00000110 결과는 attr = 0x07
attr = attr & ~BOLD; // 비트 맨끝에 있는 숫자를 바꾼다(00000111 -> 00000110)
printf("attr : ");
if (attr & BOLD){ // c언어에서는 괄호안의 값이 nonzero면 참이라고 생각한다.
printf("BOLD");
}
if (attr & ITALIC){
printf("ITALIC ");
}
if (attr & SHADOW){
printf("SHADOW ");
}
if (attr & UL){
printf("UL ");
}
printf("\n");
return 0;
}