Wednesday, December 5, 2012

C++ dynamic array vs static array

Dynamic array
char *mychar = new char[128];

Requires you to allocate and free the memory space. So if the array is created in a function and will be used in another function, this is the type to use.


Static array
char mychar[128];

The array will be destroyed after the function where the array created exits.