fork download
  1. #include <stdio.h>
  2.  
  3. void initialize_board(int rows, int cols, char board[rows][cols]) {
  4. for (int i = 0; i < rows; i++) {
  5. for (int j = 0; j < cols; j++) {
  6. board[i][j] = ' ';
  7. }
  8. }
  9. }
  10.  
  11. int main() {
  12. int rows = 4;
  13. int cols = 4;
  14. char board[rows][cols];
  15.  
  16. initialize_board(rows, cols, board);
  17.  
  18. // Print the entire board
  19. for (int i = 0; i < rows; i++) {
  20. for (int j = 0; j < cols; j++) {
  21. printf("%c ", board[i][j]);
  22. }
  23. printf("\n"); // Move to the next row after printing each row
  24. }
  25.  
  26. return 0;
  27. }
  28.  
Success #stdin #stdout 0.01s 5308KB
stdin
Standard input is empty
stdout