Contents

Views 6583 Comment 0
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
#include <stdio.h>
#include <conio.h>
#include <windows.h>

#define STD_HANDLE GetStdHandle(STD_OUTPUT_HANDLE)

void gotoxy(int x, int y)
{
    COORD Cur= {(SHORT)x, (SHORT) y};
    SetConsoleCursorPosition(STD_HANDLE, Cur);
}


void main()
{
    int x = 0;  // x좌표
    int direction = 1;  // 방향. 1이면 오른쪽, -1이면 왼쪽

    while(1)
    {
        while(!kbhit())  // 키보드가 입력되지 않는 한
        {
            _sleep(500);  // 0.5초 쉼
            gotoxy(x, 10);  // 현재 자리에 있는
            putchar(' ');  // 점을 없애기 위해 공백 출력
            x = x + direction;  // x좌표 이동
            if(x == 80) x = 0;  // 만약에 80이면 한바퀴 돌았으므로 0으로
            else if(x == 0) x = 79;  // 0이면 왼쪽으로 한바퀴 돌았으므로 오른쪽 끝 79로
            gotoxy(x, 10);  // 이동한 좌표로
            putchar('.');  // 점 출력
        }
        int key = getch();  // 키보드 입력
        if(key == 0)  // 특수키이면
        {
            key = getch();  // 입력받은 것중 나머지
        }
        if(key == 0x4b)  // 왼쪽 커서이면
            direction = -1;
        else if(key == 0x4d)  // 오른쪽 커서이면
            direction = 1;
    }
}


?

List of Articles
No. Category Subject Author Date Views
673 Develop GPL, AGPL, MPL,.. 한눈에 보는 오픈소스SW 라이선스 file hooni 2014.10.14 1272
672 Develop [js] 좋은 강연자료 & UI 자료 hooni 2014.10.06 997
671 Develop '2014 모바일 개발 트렌드' 발표자료입니다. file hooni 2014.10.02 1140
670 Develop [ios] iOS 8 개발자가 우선 알아야 할 3가지 file hooni 2014.10.02 990
669 Develop [js] jQuery 셀 병합 1 file hooni 2014.09.23 3567
668 Develop [ios] Xcode cannot run using the selected device hooni 2014.08.14 1929
667 Develop [ios] Objective-C 에서 자주 사용하는 수학 함수와 유용한 Define hooni 2014.08.08 2002
666 Develop [ios] 카테고리 확장 메소드를 찾지 못하는 경우 file hooni 2014.08.08 2121
665 Develop [ios] @property의 속성 (strong, weak, copy) 사용 경우 hooni 2014.08.08 1780
664 Develop [ios] TextField 특정 문자만 사용하도록 하기 hooni 2014.06.30 2797
663 Develop [ios] XCode에서 Provisioning Profile 여러개 중복될 때 hooni 2014.06.26 2953
662 Develop 알고리즘 성능 분석 기준 hooni 2014.06.24 2918
Board Pagination Prev 1 ... 10 11 12 13 14 15 16 17 18 19 ... 71 Next
/ 71