C++ has proper string type:
std::string
which you may find helpful here. Even if you're passing it to function that accepts const char*
, it has .c_str()
method that allows you to pass it to function that accept a pointer. If the other function needs to modify the string, you can use &str[0]
which is valid for many implementations of C++, and is required to work for C++11. Just make sure you resize() them to the correct size.
Some of the other containers in C++ are:
std::array
(C++11) Array of constant size. Better than plain old C array, as it has size()
method.
std::vector
Dynamic array (Java ArrayList
equivalent)
As for your question - there is no way to find size of a pointed array. How could you even do that? It's just a stupid pointer.