S
Sims
Hi,
if i have a code
const char * GetValue()
{
std::string szVectorValue = ...// get a std::string from the vector
return szVectorValue.c_str();
}
Is the code above safe? I think not because the value 'szVectorValue' will
be released making the const char garbage.
i could do
std::string GetValue()
{
std::string szVectorValue = ...// get a std::string from the vector
return szVectorValue;
}
but the problem is that i am using sprintf( ... )
and it would be simpler/clearer if instead of 'GetValue().c_str()' i could
do 'GetValue()'
Many thanks for your input.
Sims
if i have a code
const char * GetValue()
{
std::string szVectorValue = ...// get a std::string from the vector
return szVectorValue.c_str();
}
Is the code above safe? I think not because the value 'szVectorValue' will
be released making the const char garbage.
i could do
std::string GetValue()
{
std::string szVectorValue = ...// get a std::string from the vector
return szVectorValue;
}
but the problem is that i am using sprintf( ... )
and it would be simpler/clearer if instead of 'GetValue().c_str()' i could
do 'GetValue()'
Many thanks for your input.
Sims