Contents

조회 수 6539 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
#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
번호 분류 제목 글쓴이 날짜 조회 수
357 Develop [linux] 날짜나 파일의 내용으로 검색하는 방법(find 명령 사용) hooni 2013.04.23 8106
356 System/OS [linux] 네트워크 커널 설정.. hooni 2003.04.23 16468
355 System/OS [linux] 네트웍 트래픽 모니터링(MRTG) hooni 2003.04.23 41648
354 System/OS [linux] 데비안(debian.org) 리눅스 명령어 예제 hooni 2006.04.23 10420
353 System/OS [linux] 데스크탑환경(GNOME/KDE) 바꾸기.. hooni 2003.04.23 12101
352 System/OS [linux] 랜카드 2개 설정 & iptables 로 사설 ip.. hooni 2003.04.23 14724
351 System/OS [linux] 랜카드가 2개 일 때 네트워크 설정 hooni 2003.04.23 30011
350 System/OS [linux] 리눅스 파일시스템과 디렉토리 설명 hooni 2013.04.23 26877
349 System/OS [linux] 리눅스 활용 팁^^ hooni 2003.04.23 14629
348 System/OS [linux] 리눅스, 유닉스 CPU 이용률 확인.. hooni 2013.04.23 23371
347 System/OS [linux] 리눅스,유닉스 /proc/stat 파일 보는 법 hooni 2013.04.23 17916
346 System/OS [linux] 메일서버 세팅정보(sendmail) hooni 2003.04.23 17407
Board Pagination Prev 1 ... 64 65 66 67 68 69 70 71 72 73 ... 98 Next
/ 98