내가 C 공부할 때
순수한 마음으로 만들어 봤던 코드.
Turboc.h 헤더 파일은 그냥 재미로만 보고,
심각하게 생각하지마.
중요한건 Turboc.h 이런게 아니라,
내부 구조를 그릴수 있는 이런 내용들임.
https://gall.dcinside.com/list.php?id=programming&no=167815&page=1&search_pos=-162676&k_type=1000&keyword=%EA%B0%80%EB%82%9C%ED%95%9C%EC%BD%94%EB%8D%94&bbs=
------------------------------ Turboc.H -----------------------------------------
#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;
#define delay(n) Sleep(n)
#define randomize() srand((unsigned) time (NULL))
#define random(n) (rand()%(n))
#define clrscr() system("cls");
void gotoxy(int x, int y);
int wherex();
int wherey();
void setcursortype(CURSOR_TYPE c);
#ifndef TURBOC_PROTOTYPE_ONLY
void gotoxy(int x, int y)
{
COORD Pos = {x, y};
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), Pos);
}
int wherex()
{
CONSOLE_SCREEN_BUFFER_INFO BufInfo;
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &BufInfo);
return BufInfo.dwCursorPosition.X;
}
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
--------------------------- main.cpp ----------------------------------------------
#include "TURBOC.h"
#define LEFT 75
#define RIGHT 77
#define UP 72
#define DOWN 80
#define ESC 27
typedef struct tag_PT
{
int x;
int y;
} PT;
PT pt[] = {{34, 15}, {33, 15}, {33, 14}, {32, 14}, {31, 14}, {30, 14}, {30, 13}, {29, 13},
{28, 13}, {27, 13}, {27, 12}, {26, 12}, {25, 12}, {24, 12}, {23, 12}, {23, 11},
{22, 11}, {22, 10}, {21, 10}, {21, 9}, {21, 8}, {22, 8}, {22, 7}, {23, 7},
{23, 6}, {24, 6}, {25, 6},{25, 5}, {26, 5}, {27, 5}, {28, 5}, {29, 5},
{29, 4}, {30, 4}, {31, 4}, {32, 4}, {33, 4},{34, 4}, {34, 5}, {35, 5},
{35, 6}, {36, 6}, {36, 7}, {37, 7}, {38, 7}, {38, 6}, {39, 6},{39, 5},
{40, 5}, {41, 5}, {41, 4}, {42, 4}, {43, 4}, {44, 4}, {45, 4}, {46, 4},
{47, 4},{47, 5}, {48, 5}, {49, 5}, {49, 6}, {50, 6}, {50, 7}, {51, 7},
{52, 7}, {52, 8}, {53, 8},{53, 9}, {53, 10}, {52, 10}, {51, 10}, {51, 11},
{50, 11}, {49, 11}, {49, 12}, {48, 12},{47, 12}, {46, 12}, {46, 13}, {45, 13},
{44, 13}, {44, 14}, {43, 14}, {42, 14}, {41, 14},{41, 15}, {40, 15}, {39, 15},
{38, 15}, {38, 16}, {37, 16}, {36, 16}, {35, 16}, {35, 15}};
int main()
{
// 결과물 출력
//===============================================================
setcursortype(NOCURSOR);
int i;
for (i = 0; i < 94; i++)
{
gotoxy(pt[i].x, pt[i].y);
putch(\'*\');
Sleep(100);
}
gotoxy(34, 9);
puts("당");
Sleep(500);
gotoxy(36, 9);
puts("신");
Sleep(500);
gotoxy(38, 9);
puts("을");
Sleep(500);
bool on = true;
int ch;
for (;;)
{
if (on)
{
gotoxy(32, 11);
puts("사랑합니다");
Sleep(100);
}
else
{
gotoxy(32, 11);
puts(" ");
Sleep(100);
}
on = !on;
if ( kbhit() )
{
ch = getch();
if (ch == 0xE0)
{
}
else
{
if (ch == ESC)
{
clrscr();
gotoxy(32, 11);
puts("영원히 사랑합니다");
gotoxy(0, 20);
system("pause");
return 0;
}
}
}
}
//===============================================================
// 좌표를 파일로 저장
//===============================================================
/*
FILE *fp;
fp = fopen("Test.txt", "wt");
int ch;
int x = 35, y = 15;
for(;;)
{
if(kbhit())
{
ch = getch();
if (ch == 0xE0)
{
ch = getch();
switch (ch)
{
case UP:
y--;
gotoxy(x, y);
fprintf(fp, "{%d, %d}, ", x, y);
putch(\'*\');
break;
case DOWN:
y++;
gotoxy(x, y);
fprintf(fp, "{%d, %d}, ", x, y);
putch(\'*\');
break;
case RIGHT:
x++;
gotoxy(x, y);
fprintf(fp, "{%d, %d}, ", x, y);
putch(\'*\');
break;
case LEFT:
x--;
gotoxy(x, y);
fprintf(fp, "{%d, %d}, ", x, y);
putch(\'*\');
break;
}
}
else
{
if (ch == ESC)
{
fclose(fp);
return 0;
}
}
}
}
*/
//===============================================================
return 0;
}
댓글 영역
획득법
① NFT 발행
작성한 게시물을 NFT로 발행하면 일주일 동안 사용할 수 있습니다. (최초 1회)
② NFT 구매
다른 이용자의 NFT를 구매하면 한 달 동안 사용할 수 있습니다. (구매 시마다 갱신)
사용법
디시콘에서지갑연결시 바로 사용 가능합니다.