Is String Empty
-11
Is String Empty
bool IsStringEmpty(CString strString)
{
// Declare variables
BOOL bEmpty = true;
// Go through each character
for (int i = 0; i < strString.GetLength(); i++)
{
if (strString.GetAt(i) != ' ')
{
bEmpty = false;
break;
}
}
return bEmpty;
}
{
// Declare variables
BOOL bEmpty = true;
// Go through each character
for (int i = 0; i < strString.GetLength(); i++)
{
if (strString.GetAt(i) != ' ')
{
bEmpty = false;
break;
}
}
return bEmpty;
}






// Since CString, string, and char *, all can use the [] operator, this will work for all:
bool isStringEmpty(char * pszString)
{
return pszString[0] ? false : true;
}
// But even having this function is pretty pointless to begin with.
// You're better off just inlining it.
Which would just be...(see below)...otherwise he would have just called CString::IsEmpty. I hope anyways.
Bobby R Ward
---------------------
bobbyrward@gmail.com
CString str(" ");
str.TrimLeft();
str.TrimRight();
bool b = str.IsEmpty();