I've done a bit of basic reading and from what I've gathered .c_str() always has a null terminator.
I have a fairly simple C++ program:
int main(int argc, char** argv)
{
std::string from = "hello";
char to[20];
memcpy(to, from.c_str(), strlen(from.c_str())+1);
std::cout<< to << std::endl;
return 0;
}
Will that memcpy ensure that I copy over a null-terminated string to my variable to (provided that my string from is shorter in length)?