Empty String Overkill
-
Is it just me, or does this seem like overkill to detect an empty string...
if( strcmp( szPossiblyEmptyString, "" ) == 0 )
:doh: No shirt, no shoes, no brains, no service. -
Is it just me, or does this seem like overkill to detect an empty string...
if( strcmp( szPossiblyEmptyString, "" ) == 0 )
:doh: No shirt, no shoes, no brains, no service.Yes, I usually do
if (!(*szPossiblyEmptyString) )
But this maybe not very readable. Igor Green http://www.grigsoft.com/ - files and folders comparison tools -
Is it just me, or does this seem like overkill to detect an empty string...
if( strcmp( szPossiblyEmptyString, "" ) == 0 )
:doh: No shirt, no shoes, no brains, no service. -
if (szPossiblyEmptyString [0] == 0) That works fine for testing for an empty string. If you also want to test for a NULL pointer if (pszString == NULL || pszString [0] == 0) Tim Smith I'm going to patent thought. I have yet to see any prior art.
-
Is it just me, or does this seem like overkill to detect an empty string...
if( strcmp( szPossiblyEmptyString, "" ) == 0 )
:doh: No shirt, no shoes, no brains, no service.Definitely superfluous. ;)
"Take only what you need and leave the land as you found it." - Native American Proverb
-
Is it just me, or does this seem like overkill to detect an empty string...
if( strcmp( szPossiblyEmptyString, "" ) == 0 )
:doh: No shirt, no shoes, no brains, no service.Good Habit to inculcate.:-D