| ftp.delorie.com/archives/browse.cgi | search |
| X-Authentication-Warning: | delorie.com: mail set sender to djgpp-bounces using -f |
| Date: | Sun, 30 Nov 2003 19:08:19 +0200 |
| From: | "Eli Zaretskii" <eliz AT elta DOT co DOT il> |
| Sender: | halo1 AT zahav DOT net DOT il |
| To: | djgpp AT delorie DOT com |
| Message-Id: | <3405-Sun30Nov2003190818+0200-eliz@elta.co.il> |
| X-Mailer: | emacs 21.3.50 (via feedmail 8 I) and Blat ver 1.8.9 |
| In-reply-to: | <a8587dd9.0311300840.75e9471b@posting.google.com> |
| (cmad_x AT yahoo DOT com) | |
| Subject: | Re: C/C++ switch statement question |
| References: | <a8587dd9 DOT 0311300840 DOT 75e9471b AT posting DOT google DOT com> |
| 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 |
> From: cmad_x AT yahoo DOT com (Chris Mantoulidis)
> Newsgroups: comp.os.msdos.djgpp
> Date: 30 Nov 2003 08:40:03 -0800
>
> 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???
Right. C and C++ cannot compare strings except by calling functions
(such as strcmp).
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |