chapter 8-6: dynamically allocates memory for an array