Re: [CODE] Findind an empty string..

From: George Greer (greerga@circlemud.org)
Date: 05/20/99


On Thu, 20 May 1999, Phil Durand wrote:

>if(!GET_TITLE(ch))

Fails, because it cannot ever be NULL.

>if(GET_TITLE(ch) == "")

Fails, because the title can never be the same location as the new string
on the other side of the == sign.

>if(GET_TITLE(ch) == '\0')

This is equivalent to testing for NULL. ('\0' = 0 = NULL) [1]

>if(GET_TITLE(ch) == NULL)

Ditto.

>I mean, some of those are useless of course, and I've even tried str_cmp and
>it still doesn't figure out that the string is actually empty...

if (*GET_TITLE(ch) == '\0')
  empty;

--
George Greer            | The Ceramic Mouse & Snippets
greerga@circlemud.org   | http://developer.circlemud.org/

[1] Give or take a (void *) cast on NULL depending on your headers.
    Also different in C++ which really discourages void pointers.


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST