PDA

View Full Version : empty


Xiang
05-26-2003, 05:20 PM
Dear sir,

In the C progamming, how can the program detects an empty string, if users leave a string field empty. (other than used strlen function).

Thanks

Xiang

XtrmelyCanadian
05-27-2003, 06:00 PM
There is an IsEmpty() function in C++ dont know if its in C though.

Jason
05-27-2003, 09:47 PM
if (string == ""){
do whatever
}

that should work, you tried that?


Jason

migo
06-07-2003, 12:22 PM
You can't use "==" on strings, because this will compare the pointers, and not the string values (I am talking about regular char*, and not a more complex wrapper).

The simplest way it to check:
if( str[0] == '\0' )
{
// is empty
}