Sunday, 15 September 2013

Get end of string as const char * in C++

Get end of string as const char * in C++

Is it correct that in order to get a char pointer to the end of a string
in C++ i have to do this:
std::string str = ...
const char * end_ptr = &*str.cend();
Like dereferencing, then getting the address of the expression. Is there a
more elegant way to do this?

No comments:

Post a Comment