Here are a couple of functions I constructed for a small user interface within a program. The functions make full use of the <conio.h> library and was compiled on borlands tcwin4.5C++.
This function set up the user screen display...which was then filled with an appropriate message
Code:
void user_grid (void)
{
int i;
/* the user grid */
clrscr();
for(i = 0; i < 77; i++)
{
gotoxy(2 + i, 2);putchar('*');
gotoxy(2 + i, 5);putchar('*');
gotoxy(2 + i, 24);putchar('*');
}
for(i = 0; i < 21; i++)
{
gotoxy(2, 3 + i);putchar('*');
gotoxy(78, 3 + i);putchar('*');
}
} /* end user_grid function */
during the process of the program user messages were printed to the center of the grid. Each set of messages were cleared from the center grid by the following function..
Code:
void clrgrid (void)
{
int i;
/* Clear previous user messages */
for(i = 0; i < 16; i++)
{
gotoxy(3, 7 + i);
printf("%75c", ' ');
}
} /* end clrgrid function */
you could attempt this program to see it work
Code:
int main (void)
{
int i = 0;
user_grid();
for(i = 0; i < 10; i++)
{
gotoxy(8, 8 + i);
printf("FIRST USER MESSAGES");
}
gotoxy(10, 20);puts("Hit return to continue :");
gotoxy(34, 20);getch();
clrgrid();
for(i = 0; i < 10; i++)
{
gotoxy(8, 8 + i);
printf("SECOND USER MESSAGES");
}
return 0;
}