Code:
/* shows how to use SetConsoleCursorPosition(), in Windows */
#include <stdio.h>
#include <windows.h>
void Gotoxy(int x, int y);
void showIt(void);
int a[81] = {
{1,2,3,4,5,6,7,8,9},
{4,5,6,7,8,9,1,2,3},
{7,8,9,1,2,3,4,5,6},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{2,1,4,3,6,5,8,9,7},
{3,6,5,8,9,7,2,1,4},
{8,9,7,4,1,2,3,6,5}
};
int main(void) {
showIt();
return 0;
}
void Gotoxy(int x, int y) {
COORD coord;
coord.X = x;
coord.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}
void showIt(void) {
int i;
Gotoxy(1,5);
for(i = 0; i < 81; i+=9) {
printf(" | %d%d%d | %d%d%d | %d%d%d |\n", a[i+0],a[i+1],a[i+2],a[i+3],a[i+4],a[i+5],a[i+6],a[i+7],a[i+8]);
if(i == 18 || i == 45) printf(" +-----+-----+-----+\n");
}
}
Not the best example for you, but anyways..