Validation
At the moment my code looks like this: This code is taken from a noughts and crosses game
-------- display_grid(); count=0; while(count<9) { if(count<9) { do{ printf("%s enter you next move, '0's\n",name1); /*asks for m move by name*/ scanf("%d%d",&r0,&c0); } while((oxo[r0][c0]!='.')||(oxo[r0][c0]=='X')||(oxo[r0][c0]=='0')); { oxo[r0][c0]='0'; } count++; ------ What I want it to do is recognize if a position on the board is already taken, I know this is the answer (below) but dont know how to re-work the loop and add the below code, ive tried a few things but it doesnt work. if( r0 != -1 && c0 != -1 ) printf("The place is already occupied\n"); If you require more code it will be provided, just ask. Thx |
How about something like this:
Code:
bool valid = false; |
All times are GMT -5. The time now is 09:53 PM. |