Thanks Dave.

I'm not looking to do anything complicated; I was asking to make sure I
hadn't overlooked something obvious and simple.

Jerry

-----Original Message-----
From: Dave Seidel [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 04, 2000 11:05 AM
To: Jerry Eckert
Subject: Re: C question


No, not really.  You can fake it in C++ by overloading the "==" operator
(which is done for you by any decent string class), but that simply hides
the overhead (which can be considerable).

You'll have to just use thf if()/else if() chain.  I can think of other
solutions (e.g., a hash table) but nothing that wouldn't add significant
complexity and more to debug.   If you're on a deadline, keep it simple.
:-)

-- Dave

----- Original Message -----
From: "Jerry Eckert" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, April 04, 2000 11:51 AM
Subject: C question


> Hi Folks,
>
> I hope it's not inappropriate to ask a C language question here.
>
> Is there a more elegant way to do the equivalent of a switch statement for
a
> character string value than a chain of if (strcmp())... else if
> (strcmp())... else if.... ?
>
> What I tried to do was
>
>     switch (char-var) {
>         case "string1":
>         ...
>     }
>
> Eventually I figured out character strings aren't a data type in C.
Sigh...
>
> Thanks.
> Jerry
> (PL/I programmer struggling to learn C while writing code on a deadline
> GAK!)
>
>
> **********************************************************
> 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
> **********************************************************
>



**********************************************************
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