delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2003/11/30/11:45:36

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
From: cmad_x AT yahoo DOT com (Chris Mantoulidis)
Newsgroups: comp.os.msdos.djgpp
Subject: C/C++ switch statement question
Date: 30 Nov 2003 08:40:03 -0800
Organization: http://groups.google.com
Lines: 17
Message-ID: <a8587dd9.0311300840.75e9471b@posting.google.com>
NNTP-Posting-Host: 212.205.250.82
X-Trace: posting.google.com 1070210404 13820 127.0.0.1 (30 Nov 2003 16:40:04 GMT)
X-Complaints-To: groups-abuse AT google DOT com
NNTP-Posting-Date: Sun, 30 Nov 2003 16:40:04 +0000 (UTC)
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

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???

- Raw text -


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