turboc.h 터보C 헤더파일 soen.kr C언어 실습
아래는 soen.kr에서 프로그램 공부할때 필요한 헤더파일이다.
참고로 soen.kr은 C언어 공부하기 정말 좋게 잘 정리되어있다. 참고하라.
// 혼자 연구하는 C/C++의 도우미 헤더 파일
// 비주얼 C++ 환경에서 터보 C 스타일의 함수를 정의한다.
#ifndef TURBOC_HEADER
#define TURBOC_HEADER
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <time.h>
#include <windows.h>
typedef enum { NOCURSOR, SOLIDCURSOR, NORMALCURSOR } CURSOR_TYPE;
void clrscr();
void gotoxy(int x, int y);
int wherex();
int wherey();
void setcursortype(CURSOR_TYPE c);
#define delay(n) Sleep(n) // n/1000초만큼 시간 지연
#define randomize() srand((unsigned)time(NULL)) // 난수 발생기 초기화
#define random(n) (rand() % (n)) //0~n까지의 난수 발생
// 이 매크로가 정의되어 있으면 함수의 원형만 선언하고 정의는 하지 않는다.
#ifndef TURBOC_PROTOTYPE_ONLY
// 화면을 모두 지운다.
void clrscr()
{
system("cls");
}
// 커서를 x,y좌표로 이동시킨다.
void gotoxy(int x, int y)
{
COORD Cur;
Cur.X = x;
Cur.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), Cur);
}
// 커서의 x 좌표를 조사한다.
int wherex()
{
CONSOLE_SCREEN_BUFFER_INFO BufInfo;
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &BufInfo);
return BufInfo.dwCursorPosition.X;
}
// 커서의 y좌표를 조사한다.
int wherey()
{
CONSOLE_SCREEN_BUFFER_INFO BufInfo;
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &BufInfo);
return BufInfo.dwCursorPosition.Y;
}
// 커서를 숨기거나 다시 표시한다.
void setcursortype(CURSOR_TYPE c)
{
CONSOLE_CURSOR_INFO CurInfo;
switch (c) {
case NOCURSOR:
CurInfo.dwSize = 1;
CurInfo.bVisible = FALSE;
break;
case SOLIDCURSOR:
CurInfo.dwSize = 100;
CurInfo.bVisible = TRUE;
break;
case NORMALCURSOR:
CurInfo.dwSize = 20;
CurInfo.bVisible = TRUE;
break;
}
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &CurInfo);
}
#endif // TURBOC_PROTOTYPE_ONLY
#endif // TURBOC_HEADER
'프로그래밍' 카테고리의 다른 글
키보드 키값 얻는 프로그램 (0) | 2014.07.03 |
---|---|
scanf_s 에서 입력값을 출력 못할때 (0) | 2014.07.03 |
C언어 header 설정하는 두가지 방법 (1) | 2014.07.01 |
16비트 32비트 비트연산 방법 (0) | 2014.06.26 |
avr 어셈블리 명령어 $, 0x 의미 (0) | 2014.06.23 |