#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <conio.h>
#include <time.h>
#define WIDTH 30
#define HEIGHT 15
#if defined(_MSC_VER)
#define MY_GETCH _getch
#define MY_KBHIT _kbhit
#else
#define MY_GETCH getch
#define MY_KBHIT kbhit
#endif
void gotoxy(int x, int y){
COORD pos;
pos.X = x - 1;
pos.Y = y - 1;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);
}
void pause_any_key(void){
printf("\n아무 키나 누르면 메뉴로 돌아갑니다.\n");
MY_GETCH();
}
void test_sleep(void){
system("cls");
printf("[1] Sleep 테스트\n\n");
printf("3초 카운트다운 시작\n");
for(int i=3; i >= 1; i--){
printf("%d...\n", i);
Sleep(1000);
}
printf("완료\n");
pause_any_key();
}
void test_cls(void){
system("cls");
printf("[2] system(\"cls\") 테스트\n\n");
printf("2초 뒤 화면을 지웁니다.");
Sleep(2000);
system("cls");
printf("화면이 지워진 뒤 다시 출력되었습니다.\n");
pause_any_key();
}
void test_gotoxy(){
system("cls");
printf("[3] gotoxy 테스트\n");
Sleep(1000);
system("cls");
gotoxy(10,5);
printf("A(10, 5)");
gotoxy(20, 10);
printf("B(20, 10)");
gotoxy(30,15);
printf("C(30, 15)");
gotoxy(1, 24);
printf("좌표 출력 완료");
pause_any_key();
}
void test_getch_basic(void){
int ch;
system("cls");
printf("[4] getch 기본 입력 테스트\n\n");
printf("아무 키나 하나 누르세요: ");
ch = getch();
printf("\n\n문자 출력: ");
if (ch >= 32 && ch <= 126){
printf("%c\n", ch);
} else{
printf("(출력 불가 문자)\n");
}
printf("정수 코드값: %d\n", ch);
pause_any_key();
}
int main(void) {
int menu;
while(1){
system("cls");
printf("=== Dev-C++ 콘솔 기능 점검 묶음 ===\n\n");
printf("1. Sleep 테스트\n");
printf("2. system(\"cls\") 테스트\n");
printf("3. gotoxy 테스트\n");
printf("4. getch 기본 입력 테스트\n");
printf("5. 화살표 키 / 확장키 코드 테스트\n");
printf("6. kbhit + 이동 테스트\n");
printf("0. 종료\n\n");
printf("메뉴 선택: ");
if(scanf("%d", &menu) != 1){
while(getchar() != '\n');
continue;
}
while(getchar() != '\n');
switch(menu){
case 1: test_sleep(); break;
case 2: test_cls(); break;
case 3: test_gotoxy(); break;
case 4: test_getch_basic(); break;
// case 5: test_arrow_code(); break;
// case 6: test_kbhit_loop(); break;
case 0:
system("cls");
printf("종료합니다.\n");
return 0;
default:
printf("잘못된 메뉴입니다.\n");
Sleep(800);
}
}
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: