On Tue, 4 Apr 2000, "Jerry Eckert" <[EMAIL PROTECTED]> wrote:
> Thanks to everyone for the suggestions for comparing a list of strings.  For
> now I think I'll stay with the if..else if.. for simplicity.
> 
> One more question:
> 
> To test two strings for equality, is there a difference between
> 
>     if (strcmp(s1, s2) == 0)
> and
>     if (! strcmp(s1, s2))

I don't think so. 

BTW if you want to try make the code more readable (i.e. like the 
shell case statement you were initially trying), maybe a macro: 

#define EQ(a) (strcmp(str, (a)))

        str = set_it_somehow();

        if        ( EQ("frog") ) {
                ...
        } else if ( EQ("lizard") ) {
                ...
        } else if ( EQ("earwig") ) {
                ...
        }


I don't claim that this is much more readable (or is even working code!),
but an inspired macro or two might help...

Karl


**********************************************************
To unsubscribe from this list, send mail to
[EMAIL PROTECTED] with the following text in the
*body* (*not* the subject line) of the letter:
unsubscribe gnhlug
**********************************************************

Reply via email to