This is an example of using the Windows API version, of gotoxy() in conio.h.
Code:
#include <windows.h> //for older compilers, don't include this line
#include <stdio.h>
#include <time.h>
#define gotoxy Gotoxy // " " " " " " "
void Gotoxy(int x, int y);
int main() {
FILE *fp=NULL;
int i, j;
char choice[3];
char ch='\0';
for(i=0; i< 10; i++)
printf("\n\n\n\n\n");
do {
choice[0]='\0';
for(i=3; i< 21; i++) {
Gotoxy(1,i);
printf(" ");
}
Gotoxy(1,3);
printf("\t\t Welcome to Sudoku EZ Solver's Main Menu\n\n");
printf(" *press 'b' to benchmark this program\n\n");
printf(" *press 'l' to load a puzzle from this program\n\n");
printf(" *press 'e' to enter your own puzzle, or 'q' to quit [b/l/e/q]: ");
for(i=0; i < 9; i++) {
for(j = 0; j < 9; j++) {
grid[i][j] = 0;
}
}
fgets(choice, sizeof(choice),stdin);
if(strlen(choice) < 2)
continue;
if(choice[0] >= 'a' && choice[0] <='z')
ch=choice[0];
if(ch == 'q')
break;
for(i=3; i< 10; i++) {
Gotoxy(1,i);
printf(" ");
}
}while(ch != 'q');
printf("\n");
return 0;
}
// Include this function, for newer compilers
void Gotoxy(int x, int y) {
COORD coord;
coord.X = x;
coord.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}