www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/08/21/15:41:20

From: Bram de Greve <bram DOT degreve AT rug DOT ac DOT be>
Newsgroups: comp.os.msdos.djgpp
Subject: Newbie on the 'switch'
Date: Sat, 21 Aug 1999 19:35:23 -0700
Organization: University of Ghent, Belgium
Lines: 66
Message-ID: <37BF61EB.2DD26DC0@rug.ac.be>
NNTP-Posting-Host: sdln1p17.rug.ac.be
Mime-Version: 1.0
X-Mailer: Mozilla 4.04 [en] (Win16; I)
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

--------------AED26BC7673CE1CF2C8F683A
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi,

when you use switch like this:

switch (choice)
{
case 0: cout << "This is one thing." << endl;
        break;
case 1: cout << "This is one thing." << endl;
        break;
case 2: cout << "This is another thing." << endl;
        break;
default:cout << "Default!" << endl;

Is there any way to combine case 0 and 1 into one line l, like you
should do in Turbo Pascal or QuickBASIC (sorry :-) and VisualBASIC:

Select Case Choice
   Case 0, 1: Print "This is one thing."
   Case 2   : Print "This is another thing."
   Case Else: Print "Default!"
End Select

Tanks in advance,
Bram


--------------AED26BC7673CE1CF2C8F683A
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<HTML>
Hi,

<P>when you use switch like this:

<P><TT>switch (choice)</TT>
<BR><TT>{</TT>
<BR><TT>case 0: cout &lt;&lt; "This is one thing." &lt;&lt; endl;</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;</TT>
<BR><TT>case 1: cout &lt;&lt; "This is one thing." &lt;&lt; endl;</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;</TT>
<BR><TT>case 2: cout &lt;&lt; "This is another thing." &lt;&lt; endl;</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;</TT>
<BR><TT>default:cout &lt;&lt; "Default!" &lt;&lt; endl;</TT>

<P>Is there any way to combine case 0 and 1 into one line l, like you should
do in Turbo Pascal or QuickBASIC (sorry :-) and VisualBASIC:

<P><TT>Select Case Choice</TT>
<BR><TT>&nbsp;&nbsp; Case 0, 1: Print "This is one thing."</TT>
<BR><TT>&nbsp;&nbsp; Case 2&nbsp;&nbsp; : Print "This is another thing."</TT>
<BR><TT>&nbsp;&nbsp; Case Else: Print "Default!"</TT>
<BR><TT>End Select</TT>

<P>Tanks in advance,
<BR>Bram
<BR>&nbsp;</HTML>

--------------AED26BC7673CE1CF2C8F683A--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019