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
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
}
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.