Notice
Recent Posts
Recent Comments
Creative Code
maxMidMin.c (최대,중간,최소값 구하기) 본문
#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 : 0x%02x\n",attr); // 맨끝에 있는 8비트만 출력
return 0;
}
'C Programming' 카테고리의 다른 글
procScore.c (배열 성적평균구하기) (0) | 2023.08.01 |
---|---|
oddEven.c (홀수,짝수 판별) (0) | 2023.07.31 |
letterAttribute.c (비트연산) (1) | 2023.07.31 |
isOrdinary.c (평년,윤년 구분하기) (0) | 2023.07.31 |
isLeap.c(윤년,평년 구분) (0) | 2023.07.31 |