the following program is not complete yet so don't judge on that.(I haven't made the win condition yet etc)
#include <stdio.h> //Date:17/10/2022, By Raunak Shahi
int main(void)
{
int i=0;
int coord=0;
char c1,c2,c3,c4,c5,c6,c7,c8,c9='';
char input='';
double a;
printf("Here's the number assigned to each cell:\n"); //Showing the user the coordinates of each cell through the demo table
printf(" ___________ \n");
printf("| 1 | 2 | 3 |\n");
printf("|___|___|___|\n");
printf("| 4 | 5 | 6 |\n");
printf("|___|___|___|\n");
printf("| 7 | 8 | 9 |\n");
printf("|___|___|___|\n");
for(i=1;i<=9;i++){ //Printing the table each turn until the game is finished
if(i%2==0){
input='O';
printf("Nought's turn, enter a coordinate:");
}else{
input='X';
printf("Cross's turn, enter a coorinate:");
}
scanf("%lf",a);
coord=(int)a;
switch(coord){
case 1:
c1=input;
break;
case 2:
c2=input;
break;
case 3:
c3=input;
break;
case 4:
c4=input;
break;
case 5:
c5=input;
break;
case 6:
c6=input;
case 7:
c7=input;
break;
case 8:
c8=input;
break;
case 9:
c9=input;
break;
}
printf(" ___________ \n");
printf("| %s | %s | %s |\n", c1, c2, c3);
printf("|___|___|___|\n");
printf("| %s | %s | %s |\n", c4, c5, c6);
printf("|___|___|___|\n");
printf("| %s | %s | %s |\n", c7, c8, c9);
printf("|___|___|___|\n");
}
return 0;
}
When I run it, it asks me the coordinate for cross, and then nothing happens, even though it should print the table and then ask nought player for their move and I do not understand why, I'm a beginner please help!