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
849 System/OS [linux] 쉘 환경변수 PS1(프롬프트) hooni 2003.04.23 13563
848 Develop [c++] mfc 간단한 파일 입출력 예제 hooni 2013.04.23 13559
847 System/OS [linux] 간단한 vi편집기 사용 명령 hooni 2003.04.23 13536
846 System/OS [linux] 기존 환경설정 저장하면서 커널 컴파일.. hooni 2003.04.23 13534
845 System/OS [ms-sql] 프로시져 예제.. file hooni 2013.04.23 13503
844 System/OS [linux] 프로그램 설치방법 (내공쌓기) hooni 2003.04.23 13495
843 Develop [c] 기본 자료형(int)이 표현할 수 없는 큰 수(Big number)를 덧셈하는 코드. 1 hooni 2013.04.23 13484
842 System/OS [linux] 쉘 스크립트에 대한 설명과 예제.. hooni 2003.04.23 13473
841 Algorithm 스터디 자료, 암호화에 대해서.. 나중에 볼 ppt.. file hooni 2013.04.23 13445
840 System/OS [linux] Xwindow/Xmanager 사용 hooni 2003.04.23 13404
839 Develop [ios] 간단한 방법으로 OS버전 확인하기. hooni 2013.09.24 13392
838 Develop [c#] 파일(File) 쓰기 ㅎㅎ hooni 2013.04.23 13321
Board Pagination Prev 1 ... 23 24 25 26 27 28 29 30 31 32 ... 98 Next
/ 98