Personally I wouldent use scanf to get the input, I'd use fgets() instead. By getting th input as a sting first your program won't crash if the user enters something wrong by accident. You could then read the first three characters in sequence to represent something like:
- x position on grid
- y position
- number to change cell to
For drawing you grid theres also some ascii characters for borders you can use. Heres an example of a basic function I made to draw a grid for a chess board:
Code:
#include <stdio.h>
void DrawBoard()
{
for(int y=0; y<18; y++)
for(int x=0; x<26; x++)
if(y==0)
if(x==25) printf(" \n");
else if(x%3==2) putchar(65+(x/3));
else putchar(' ');
else if (y==1)
if(x==0) putchar(' ');
else if(x==1) putchar(218);
else if(x==25) printf("%c\n", 191);
else if(x%3==1) putchar(194);
else putchar(196);
else if(y==17)
if(x==0) putchar(' ');
else if(x==1) putchar(192);
else if(x==25) printf("%c\n", 217);
else if(x%3==1) putchar(193);
else putchar(196);
else if(y%2==1)
if(x==0) putchar(' ');
else if(x==1) putchar(195);
else if(x==25) printf("%c\n", 180);
else if(x%3==1) putchar(197);
else putchar(196);
else
if (x==0) putchar(48+(y/2));
else if(x==25) printf("%c\n", 179);
else if(x%3==1) putchar(179);
else if(x%3==2) printf(" ");//contents goes here
}
int main()
{
DrawBoard();
getchar();
}
Its only 8*8 so you would need an extra tile in each dim. Also theres some double border chars to which would look good to divide the 3*3 sections. If you want you could find thier codes on an ascii chart.