No, the standard does not provide such a guarantee. The only guarantee in the C ++ standard is that the return value points to a char array with the same contents as std::string , plus nul-terminator.
Thus, it would be standard-compliant for the implementation to maintain its internal representation in a way different from the C-string, and to highlight the C-string on the fly when you call c_str , although I'm pretty sure that the widely used STL implementation on doesn't really do that.
Now, with regard to C ++ 0x, I heard (although now I find it difficult to find documentation for this) that one of the changes will be the requirement that std::string work continuous storage (a similar requirement already exists for std::vector ) . Thus, in this case, you can access the range from &str[0] to &str[0]+str.length()-1 , as if it were a C-string without nul-terminator.
source share