Views 6541 Votes 0 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
325 Develop [js] 스타크래프트(starcraft).. file hooni 2013.04.23 6640
324 Develop [js] 툴팁.. 좋은거.. (tooltip) file hooni 2013.04.23 7058
323 PPT [ppt] Magic URLs & Hidden Form Fields 에 대해.. ㅋㅋ file hooni 2013.04.23 12093
322 Develop [web] URL 인코딩 방법.. 테이블.. ㅋㅋ hooni 2013.04.23 7142
321 Develop [js] get방식, url이후 모두 그대로 읽어오기.. hooni 2013.04.23 6841
320 Develop [vc++] 게임 소스 등.. ㅋㅋ file hooni 2013.04.23 18347
319 Develop [c] 격자 직사각형 넓이 구하기 file hooni 2013.04.23 7457
318 Develop [c] 최단거리 알고리즘 & 예제소스.. 13 file hooni 2013.04.23 10171
317 Develop [c] vc++ 에서 clrscr(), gotoxy() 함수 사용하기.. hooni 2013.04.23 14254
316 Develop [c] 오목.. 간단한 소스 ㅋㅋ file hooni 2013.04.23 9658
315 Etc 개발자가 알아야할 10가지 보안팁으로 코드 보호하기 hooni 2013.04.23 16403
314 Develop [c] 오류체크(CRC 체크 ) 소스 2 hooni 2013.04.23 8121
313 Develop [c] 네트워크 정보 알아보기 file hooni 2013.04.23 16122
312 Develop [c] alarm()함수 설명과 간단한 예제 file hooni 2013.04.23 6678
311 Develop [c] selec()를 이용한 입출력 다중화 file hooni 2013.04.23 8259
310 Develop [c] 다중연결 서버 만들기 #4 - thread 사용 file hooni 2013.04.23 23702
Board Pagination Prev 1 ... 52 53 54 55 56 ... 74 Next
/ 74