1

What the benefits and disadvantage of using an array of pointers vs a multidimensional array and vica verse in C or C++. They both seem the same to me. For example, take the following

char *people[] = {"Alex", "Tom", "Peter"};

Versus

char people[][9] = {"Alex", "Tom", "Peter"};
Casper Beyer
  • 2,077
  • 1
  • 21
  • 35
user2898696
  • 27
  • 1
  • 4

1 Answers1

5

multidimensional arrays are easier to work with, whereas pointer arrays sometimes result in a faster program.

multidimensional arrays cant be modified, pointer arrays can simply be changed to point elsewhere anytime.

POINTER ARRAYS: pointer arrays MULTIDIMENSIONAL ARRAYS multi-d arrays

Not to mention those unused memory space, such a waste.

justomat
  • 67
  • 1
  • 6