fork download
  1. #include <iostream>
  2.  
  3. #define ROAD '.';
  4.  
  5. void printBoard(char **board, unsigned int y, unsigned int x){
  6. for (auto i = 0; i < y; i++){
  7. for (auto j = 0; j < x; j++){
  8. std::cout << board[i][j];
  9. }
  10. std::cout<< std::endl;
  11. }
  12. }
  13.  
  14.  
  15. void readBoard(char **board, unsigned int y, unsigned int x){
  16. board = new char *[y];
  17. for (unsigned int i = 0; i < y; i++){
  18. board[i] = new char[x];
  19. }
  20.  
  21. for (auto i = 0; i < y; i++){
  22. for (auto j = 0; j < x; j++){
  23. board[i][j] = ROAD;
  24. }
  25. }
  26. printBoard(board,y, x);
  27. }
  28.  
  29. void createBoard(char **board, unsigned int y, unsigned int x){
  30. board = new char * [y];
  31. for (auto i = 0; i < y; i++){
  32. board[i] = new char [x];
  33. }
  34. }
  35.  
  36.  
  37. int main(){
  38.  
  39. char **board = nullptr;
  40. int y = 10;
  41. int x = 10;
  42. createBoard(board, y, x);
  43. readBoard(board, y, x);
  44.  
  45. return 0;
  46. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
..........
..........
..........
..........
..........
..........
..........
..........
..........
..........