Hello, i'm reviewing the exercise from the book and trying to understand the point. Basically it creates a static array and declares uninitialized char pointer. Then it allocated memory dynamically to the same char pointer. What i don't understand why is the program using strcpy() to copy string into newly allocated location instead of just setting a pointer to that memory address. Unless the author just intended to illustrate that theres a function that can do just that. Here's the snippet of what i mean. Thanks for the help.
char monster[4] = {'f','o','x'};
char *p = new char[strlen(monster) + 1];
cout << monster << ":" << &monster;
//p = monster;
strcpy(p,monster); // why not just assign memory location to p ?
cout << endl;
cout << p << ": " << &p;
//delete []p; // can't delocate memory ?