Contents

조회 수 6542 댓글 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
번호 분류 제목 글쓴이 날짜 조회 수
285 System/OS [mac] 컨텍스트(Context) 메뉴 "다음으로 열기" 내용 정리 hooni 2013.07.10 18797
284 System/OS [mac] 패키지 매니저, MacPort hooni 2015.01.03 975
283 System/OS [mac][추천 무료앱] 구름 입력기 - 국내 맥 사용자를 위한 한글 대안 입력기 1 file hooni 2015.01.04 2160
282 Develop [matlab] ZigZag-Scanning (2-D Array) file hooni 2016.10.15 1991
281 Develop [matlab] 정보은닉 스테가노그래피(Steganography) 수업 file hooni 2016.10.03 684
280 Develop [maven] Mac OS에 메이븐(maven) 설치하기 file hooni 2015.01.21 1110
279 System/OS [ms-sql] 서브스트링(substring), 프로시저(SP) 작성 예제 hooni 2013.04.23 41296
278 System/OS [ms-sql] 프로시져 예제.. file hooni 2013.04.23 13406
277 Database [mysql] CPU 점유율이 높을 때 확인할 내용 hooni 2015.08.26 6649
276 Database [mysql] DB->Text, Text->DB 변환 hooni 2003.04.23 12129
275 Database [mysql] ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement. hooni 2017.12.15 1202
274 Database [mysql] error while loading shared libraries: libmysqlclient.so.10: hooni 2003.04.23 12663
Board Pagination Prev 1 ... 70 71 72 73 74 75 76 77 78 79 ... 98 Next
/ 98