2010년 5월 23일 일요일

clrscr()

Clear Screen의 약자이며 이름 그대로 화면을 깔끔하게 지우고 커서를 화면 좌상단으로 옮긴다. 화면에 이미 출력된 내용을 지우고 새로운 내용을 출력하고자 할 때 이 명령을 사용한다. 특별한 형식은 없고 일종의 함수이므로 뒤에 빈 괄호와 세미콜론만 붙이면 된다. 즉 언제든지 clrscr(); 만 호출하면 화면이 깨끗하게 지워진다.

#include <stdio.h>
#include <conio.h>
#include <windows.h>
void gotoxy(int x, int y)             /* 커서이동 함수 부분 */
{
    COORD XY = {x, y};
    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), XY);
}

int main(void)
{
 
  printf("1\n");
  system("cls"); // clrscr()로 대체 conio.h 파일 포함!
  gotoxy(37,12);
 
  printf("center\n");
 
 return 0;
}

댓글 없음:

댓글 쓰기