delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2003/11/30/12:15:07

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
Message-ID: <3FCA24D3.95AF2A3C@phekda.freeserve.co.uk>
Date: Sun, 30 Nov 2003 17:11:47 +0000
From: Richard Dawe <rich AT phekda DOT freeserve DOT co DOT uk>
X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.2.23 i586)
X-Accept-Language: de,fr
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Subject: Re: C/C++ switch statement question
References: <a8587dd9 DOT 0311300840 DOT 75e9471b AT posting DOT google DOT com>
Lines: 29
NNTP-Posting-Host: 62.3.251.102
X-Trace: 1070211962 mercury.nildram.net 109 62.3.251.102
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Hello.

Chris Mantoulidis wrote:
> in my c++ program i use the switch statement with a string parameter.
> for example
> 
> string s;
> cin >> s;
> switch (s)
> {
> .......
> }
> 
> but i get an error saying "switch quantity not an integer"... probably
> the switch needs an integer parameter and probably that's the same
> with C (and a char * in the example).
> 
> so... there is no way that i can use switch for a string?
> 
> i have to use IF-ELSE???

Yes.

Regards,

-- 
Richard Dawe [ http://homepages.nildram.co.uk/~phekda/richdawe/ ]

"You can't evaluate a man by logic alone." -- McCoy, "I, Mudd", Star Trek

- Raw text -


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