Original Post
Ok, this is my source code for a Connect 4 game, however I am having trouble getting things to work correctly Firstly... I need help passing a 2D array into a function..How can that be done? >>> shows where the problem lies Any help is greatly appreciated! #include using namespace std; //Function Prototypes void Player_Turn(int&); void The_Board(int, int, int, int, int, bool&); // Draws Board To Screen void Drop(int, char[][7], bool, int, int); int main(char board) { // Intializes board const int MAX_ROWS = 6; const int MAX_COLUMN = 7; int player=1; bool blank = true; //Used to keep track of # of moves for high score int drop1=0; int drop2=0; Player_Turn(player); cout << endl; >>>>>>Drop(player, board[][7], blank, drop1, drop2); The_Board(player, drop1, drop2, MAX_ROWS, MAX_COLUMN, blank); // Keeps screen up to display board int hold = 0; cin >> hold; return 0; } //Function determines which players turn it is to play piece void Player_Turn(int &player) { if(player == 1) { cout << "Player 1's Turn " << endl; player = 2; } else if(player == 2) { cout << "Player 2's Turn " << endl; player = 1; } } //Function displays the board void The_Board(int player, int drop1, int drop2, int MAX_ROWS, int MAX_COLUMN, bool ␣) { char board[6][7];; char bottom = '='; char side = '|'; int tick = 0; //Clears Array of garbage for(int clear_row = 0; clear_row < 7; clear_row++) { for(int clear_col= 0; clear_col < 6; clear_col++) board[clear_row][clear_col]; } for (int row = 0; row < 7; row++) { cout << side; for (int column = 0; column < 6; column++) { cout << board[row][column] << side; } cout << endl; } for(int loop = 0; loop < 13; loop++) cout << bottom; cout << endl; } //Function determines where player chooses to drop piece void Drop(int player, char board[][7], bool blank, int drop1, int drop2) { int choice; cout << "Please choose a column (1-7):"; cin >> choice; choice = (choice - 1) ; if (choice > 6 || choice < 0) cout << "Invalid Column Choice, Choose Another" << endl; do{ if(player == 1) { for (int i=6; i > 0; i--) { if(board[choice] != '\0' || board[choice] != ' ') { blank = true; drop1++; board[choice] = 1; } else { blank = false; i+=1; } }} else if(player == 2) for (int i=6; i > 0; i--) { if(board[choice] != '\0' || board[choice] != ' ') { blank = true; drop2++; board[choice] = 2; } else { blank = false; i+=1; } } }while(!blank); }