www.delorie.com/archives/browse.cgi | search |
From: | "Steve Chalkley" <sjc AT conceptii DOT co DOT uk> |
Newsgroups: | comp.os.msdos.djgpp |
References: | <88v09h$64n$1 AT nets3 DOT rz DOT RWTH-Aachen DOT DE> |
Subject: | Re: rectification about switch ... such a big mistake |
Lines: | 65 |
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: | <MIvu4.1417$Dc5.30849@news2-win.server.ntlworld.com> |
Date: | Mon, 28 Feb 2000 14:36:04 -0000 |
NNTP-Posting-Host: | 194.168.10.118 |
X-Complaints-To: | abuse AT net DOT ntl DOT com |
X-Trace: | news2-win.server.ntlworld.com 951748524 194.168.10.118 (Mon, 28 Feb 2000 14:35:24 GMT) |
NNTP-Posting-Date: | Mon, 28 Feb 2000 14:35:24 GMT |
Organization: | ntl News Service |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Reply-To: | djgpp AT delorie DOT com |
If your prompt is printed twice then your loop is being executed twice! Try printing the hex value of charact after it is read, it might tell you something interesting... Steve Chalkley Florent BUDILLON <florent AT oih DOT rwth-aachen DOT de> wrote in message news:88v09h$64n$1 AT nets3 DOT rz DOT RWTH-Aachen DOT DE... > Sorry but in the first message there is a big mistake. I didn't to write all > the program because it's quite long. So if somebody want to help me, I made > it right. > > I wrote this function which works quite well except one thing, the second > time I use the function the program writes twice "Absolute (enter M) or > relative (enter A) displacement" without doing really something wrong but it > looks bad on the screen. The defect comes from the switch, and in fact it's > when the character is 'M' only (not with 'A') . Do you know if there any bug > with this "switch" or I did it wrong. > > Thanks for helping me ... > > > > int input_one_char(char CHAINEcharact[]) > > { > int test=0,check=0; > char charact; > > do > { > printf("\r%s : ",CHAINEcharact); > fflush(stdout); > test=scanf("%c*[^\n]",&charact); > charact=toupper(charact); > switch (charact) > { > case 'A': > case 'M': > check=1; > }; > } while ((test!=1)||(check==0)); > > return charact; > > int main() > > ...... > > Node->Type=input_one_char("Absolute (enter M) or relative (enter A) > displacement"); > > ..... > > >
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |