Creative Code

maxMidMin.c (최대,중간,최소값 구하기) 본문

C Programming

maxMidMin.c (최대,중간,최소값 구하기)

빛하루 2023. 7. 31. 20:34
#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;
}