X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f X-Authentication-Warning: server2.shellworld.net: jdashiel owned process doing -bs Date: Sun, 30 Nov 2003 20:20:39 -0500 (EST) From: Jude DaShiell To: djgpp AT delorie DOT com Subject: Re: C/C++ switch statement question In-Reply-To: <3FCA24D3.95AF2A3C@phekda.freeserve.co.uk> Message-ID: References: <3FCA24D3 DOT 95AF2A3C AT phekda DOT freeserve DOT co DOT uk> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk First, put an error message in as default: value for switch. Then you might try an integer cast for the string value before switch gets to have the variable. On Sun, 30 Nov 2003, Richard Dawe wrote: > 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 >