Re: Multiple Case Values

From: David McKen (cic_3_b@yahoo.com)
Date: 02/11/02


If you want you can probably do this
First test for one of the 4 cardinal points then refine your search
if the second char in the string is NULL (\0) then that means you
retun the value for "N" if the second char is something else you can
test it and if it has a value you want then return the appropriate
value else return an error

//This should explain my point
int whichway(char *dir);
{
   switch(dir[0]) //only test the 1st char of the string
   {
      case "N":
        switch(dir[1]){
          case "\0"    // then there was nothing else
            return 0;
          case "E"     // in this case the string was NE
            return 1;
          case "W"
            return x;  // return whatever you want
          default:
            return -EError;
           //the string was Nx with x being a value other than E or W
           //you can return an error or you can treat this as "N"
        }
      case "E":
        return 2;
  ::snip::
   }
   return -EError;
}

--- James Browning <countkase@hotmail.com> wrote:
> From: Bejhan Jetha <nhlstar6@YAHOO.COM>
> >I know C doesn't support multiple case values but is there another
> way to
> >make it so you can still have two letters without using case
> values?
>
> you mean like
>
> int whichway(char *dir);
>   {
>     switch(dir)
>       {
>         case "N":
>           return 0;
>         case "NE":
>           return 1;
>         case "E":
>           return 2;
> ::snip::
>       }
>     return -EError;
>   }

__________________________________________________
Do You Yahoo!?
Send FREE Valentine eCards with Yahoo! Greetings!
http://greetings.yahoo.com

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   | Newbie List:  http://groups.yahoo.com/group/circle-newbies/   |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 06/25/03 PDT