c++ dynamic array names -
i able change name of array referring when printing it. change "placeholder" current moves. want current editable, once switched moves, i'd lock value. there way accomplish or better way trying do? stupid tic tac toe game in use wasd move cursor (asterisk), , k mark position (x). know how "ai" stuck on this. thanks!
*| | ----- | | ----- | | x| | ----- | | ----- | | char current[3][3] {{' ', ' ', ' '}, { ' ', ' ', ' ' }, { ' ', ' ', ' ' }}; char moves[3][3] {{' ', ' ', ' '}, { ' ', ' ', ' ' }, { ' ', ' ', ' ' }}; void printboard(){ system("cls"); cout << placeholder[0][2] << '|' << placeholder[1][2] << '|' << placeholder[2][2] << '\n'; cout << "-----\n"; cout << placeholder[0][1] << '|' << placeholder[1][1] << '|' << placeholder[2][1] << '\n'; cout << "-----\n"; cout << placeholder[0][0] << '|' << placeholder[1][0] << '|' << placeholder[2][0] << '\n'; }
pass array want print parameter:
void printboard(const char (&array[3][3])) { cout << array[0][2] << '|' << array[1][2] << '|' << array[2][2] ... } printboard(current); printboard(moves);
also might improve code for
loops print arrays.
Comments
Post a Comment