Tech Support > Computers & Technology > Programming > Re: What is the difference between NULL string and empty string
Re: What is the difference between NULL string and empty string
Posted by Eric on April 7th, 2005


If str is NULL, then no space/variable is allocated in memory to hold
any string. The space requirements are only the size of str. If str is
"", then in addition to the space allocated for str, some space is
allocated to hold the emply string.

Whether the two tests are necessary, really depends on the
functionality that is to be implemented. The first test checks whether
anything at all has been passed to sFunction. A failure of this test
might be interpreted as an error condition (failure in allocation the
space required for the string). The failure of the second test might be
a perfectly valid option or a sematix problem, basically any condition
where an empty string can occure.

Eric