아래 소스에서 도대체 무엇이 잘못된건지..도스창에 아무것도 나타나지 않습니다.
어디간 틀린건가요?
#include <stdio.h>
#define ESCAPE 27
#define OFFSET 32
struct sline {
int row;
int col;
char *string;
};
static struct sline screen1[] = {
{5, 5, "Do You Want To Know About"},
{7, 10, "1. What This Program Does"},
{9, 10, "2. How This Program Works"},
{11, 10, "3. Exit This Program"},
{13, 10, "Enter # AND RETURN"}
};
int size1 = sizeof(screen1) / sizeof(struct sline);
static struct sline screen2[] = {
{5, 5, "It Demonstrates Menu Selections"},
{7, 5, "Enter C To Go Back"},
};
int size2 = sizeof(screen2) / sizeof(struct sline);
static struct sline screen3[] = {
{5, 5, " "},
{5, 5, "Enter C To Go To Main Menu"},
};
int size3 = sizeof(screen3) / sizeof(struct sline);
static struct sline screen4[] = {
{5, 5, "This Program Is Written In C"},
{75, 5, "Enter C To Go To Main Menu"},
};
int size4 = sizeof(screen4) / sizeof(struct sline);
void main(void)
{
int c;
int d = 0;
while (1){
/* 메인화면 보여주기 */
if (d == 0) dspscr(screen1, size1);
cursor(20, 20);
c = getchar();
switch (c){
case '1':
dspscr(screen2, size2);
keyin('C');
d = 0;
break;
case '2':
dspscr(screen3, size3);
keyin('C');
d = 0;
break;
case '3':
exit(0);
break;
default:
d = 1;
break;
} /* end: switch */
} /* end: while */
} /* end: main */
dspscr(screen, numline)
/* 화면 보여주기 */
struct sline screen[]; /* 줄의 배열 */
int numline; /* 배열에 있는 숫자 */
{
register int i;
clrsc();
for (i = 0; i < numline; i++){
dspline(&screen[i]);
}
return 0;
}
dspline(line)
/* prints line on terminal screen */
struct sline *line; /* line to print */
{
cursor(line->row, line->col);
strout(line->string);
return 0;
}
cursor(row, col)
/* positions cursor at row.col
no check made on validity of row and col
this is terminal dependent */
int row;
int col;
{
putchar(ESCAPE);
putchar('=');
putchar(OFFSET + row);
putchar(OFFSET + col);
printf("\n\n");
return;
}
strout(string)
/* outputs a string to terminal,
not including null char */
/* no check is made for error on outputs */
char *string; /* string to outputs */
{
while (*string){
putchar(*string++);
}
return 0;
}
clrsc()
/* clears the screen */
/* this is terminal dependent */
{
putchar(ESCAPE);
putchar('V');
putchar(ESCAPE);
putchar('T');
putchar(ESCAPE);
putchar('O');
putchar('@');
putchar(ESCAPE);
putchar('9');
putchar('P');
return 0;
}
keyin(chr)
/* waits till chr is pressed */
int chr; /* character to wait for */
{
while (1){
cursor(20, 20);
if (chr == toupper(getchar())) break;
}
return chr;
}
|