Switch problem - Kdevelop 2.0.1

Bryan, Bill bill.bryan at eds.com
Wed Nov 14 17:41:58 GMT 2001


In your sel declaration, you are declaring the 
sel variable to be an integer.  In your case
statement, the quotes means that the values are
text.  This is why it does not work.  If you compare
an integer with value of 1, its binary value is 1.
If you look at the character of '1', it has a binary
value of x31 ( hexidecimal 31 ) or a value of 49
( in decimal ).  These two will not be equal.  Make
sure that you are not confusing char with integers.


-----Original Message-----
From: James Allen [mailto:jallen at mandtbank.com]
Sent: Wednesday, November 14, 2001 11:45 AM
To: kdevelop at barney.cs.uni-potsdam.de
Subject: Switch problem - Kdevelop 2.0.1


Redhat 7.2
Kdevelop 2.0.1
The following switch statement does not work with single quotes around the
case constant expression (works if the single quotes are removed):

int sel=0;
switch(sel)
    {
     case '1' :          gather(0);               break:
     case '2' :          prntout(front,0);      break;
     case '3' :          prntout(front,1);      break;
     case '4' :          stats(front);             break;
     case '5' :          erase(front);            break;
     case '6' :          convert();                break;
     case '7' :          
             {
              wrt_all(front);
              clrscr();
              exit(0);
              }
     default:
              {
               printf(( "     Please input 1 thru 7 only.\n");
               break;
               }

Another switch in a different function (same program) works fine with the
single quotes.


-
to unsubscribe from this list send an email to kdevelop-request at kdevelop.org
with the following body:
unsubscribe »your-email-address«

-
to unsubscribe from this list send an email to kdevelop-request at kdevelop.org with the following body:
unsubscribe »your-email-address«



More information about the KDevelop mailing list