In C++, what\'s the difference between
char *a = new char[10];
and
char *a = new char(10);
Thanks!
I would rather use:
size_t size = 10; //or any other size
std::string buff(size, 0); //or: std::string buff(size, '\0');
Now if you must use the char* buff, then you can use:
&buff[0]
When you need to use const char* then you can use:
buff.c_str()
The big advantage is that you don't need to deallocate the memory, stl take care of this for you. The next advantage is that you can use all of the stl string functions