M
Mike Copeland
The following routine seemed to work...until I used it twice in the
same program. 2nd time through, the "static string" retained the value
produced in the first usage call. 8<{{
Obviously, I don't know how to use "static" to return a string value,
but there must be way(s) to do this. Please advise. TIA
string FileFunctions::removeExtension(string strFileName)
{
static string strRoot = strFileName;
size_t pos1 = strRoot.find_last_of(".");
if(pos1 != string::npos) strRoot.erase(pos1);
return strRoot;
} // removeExtension
same program. 2nd time through, the "static string" retained the value
produced in the first usage call. 8<{{
Obviously, I don't know how to use "static" to return a string value,
but there must be way(s) to do this. Please advise. TIA
string FileFunctions::removeExtension(string strFileName)
{
static string strRoot = strFileName;
size_t pos1 = strRoot.find_last_of(".");
if(pos1 != string::npos) strRoot.erase(pos1);
return strRoot;
} // removeExtension