Quote Originally Posted by manasij7479 View Post
Probably not , as:
Code:
std::cout<<std::strlen(std::string("").c_str());
prints 0.
Think about the difference between what you've done there and the scenario that I just described. To illustrate:

Code:
#include <iostream>
#include <string>
#include <cassert>
#include <cstring>

void funcThatRequiresNonEmpty_C_String( const char* string ) // <-- And yes, some poorly written C style APIs assume on blind faith that they get a non-empty string.
{
    assert( std::strlen( string ) > 0 );
}

int main()
{
    const std::string badIdea( 20, '\0' );
    
    if ( ! badIdea.empty() )
    {
        funcThatRequiresNonEmpty_C_String( badIdea.c_str() );
    }
}