delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/06/12/20:30:40

From: "Fredrik Persson" <irnman AT rocketmail DOT com>
Newsgroups: comp.os.msdos.djgpp
References: <8hrgn0$e19$1 AT nnrp1 DOT deja DOT com> <5te05.12211$Za1 DOT 193667 AT newsc DOT telia DOT net> <uim3ksca9esukpf6huhdjlbrcrgp004i10 AT 4ax DOT com>
Subject: re: char to string
Lines: 45
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2615.200
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200
Message-ID: <yU715.12920$Za1.201137@newsc.telia.net>
Date: Mon, 12 Jun 2000 16:06:54 GMT
NNTP-Posting-Host: 62.20.164.38
X-Complaints-To: abuse AT telia DOT com
X-Trace: newsc.telia.net 960826014 62.20.164.38 (Mon, 12 Jun 2000 18:06:54 MET DST)
NNTP-Posting-Date: Mon, 12 Jun 2000 18:06:54 MET DST
Organization: Telia Internet
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

ok ok i was a little hasty but it isnt so hard..

switch accepts ints and chars so what u have to do if u dont wanna use:

if

else if
 and so on..

u just gotta transfer your string into chars possibly an array of chars
witch then will be used by the switch command...


Chris Mears <cmears AT bigpond DOT com> skrev i
diskussionsgruppsmeddelandet:uim3ksca9esukpf6huhdjlbrcrgp004i10 AT 4ax DOT com...
> On Fri, 09 Jun 2000 22:46:25 GMT, that hoopy frood Fredrik Persson
> scribbled the following:
>
> >it isnt hard at all u do the same:
> >
> >string answer;
> >switch(answer)
> >{
> >case "alt 1":
> >cout<<"bla bla";
> >break;
> >
> >and so on...
>
> Not quite.
>
> [...]
> switch.cc:9: switch quantity not an integer
> switch.cc:10: case label `"alt 1"' does not reduce to an integer
> constant
>
> The switch construct only works with integral types.
>
> --
> Chris Mears
> ICQ: 36697123




- Raw text -


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