| delorie.com/archives/browse.cgi | search |
| 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 <jdashiel AT shellworld DOT net> |
| To: | djgpp AT delorie DOT com |
| Subject: | Re: C/C++ switch statement question |
| In-Reply-To: | <3FCA24D3.95AF2A3C@phekda.freeserve.co.uk> |
| Message-ID: | <Pine.BSF.4.58.0311302017510.74589@server2.shellworld.net> |
| References: | <a8587dd9 DOT 0311300840 DOT 75e9471b AT posting DOT google DOT com> |
| <3FCA24D3 DOT 95AF2A3C AT phekda DOT freeserve DOT co DOT uk> | |
| MIME-Version: | 1.0 |
| 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 |
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
>
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |