1

Hi I have 2 functions: one to create a 2d array of 10x15 and a second function to insert a character in a given slot inside the array.

void printTab(char tab[][15]);
void insertCharacter(int x, int y, char *letter, char tab[][15]);

int main() {
  char tab[10][15];

  insertCharacter(6, 6, 'x', tab);
  printTab(&tab);
  return 0;
}

void insertCharacter(int x, int y, char *letter, char tab[][15]) {
  tab[x][y] = car;
}

void printTab(char tab[][15]) {
  int i, j;
  for (i = 0; i < 10; i++) {
    printf("\n");
    for (j = 0; j < 15; j++) {

      printf(" ");
    }
  }
}

As an aside question: should I initialize the 2d array first and then print it out or is it ok to do all this in one function ?

omar
  • 401
  • 1
  • 7
  • 26

0 Answers0