| delorie.com/archives/browse.cgi | search |
| X-Authentication-Warning: | delorie.com: mailnull set sender to djgpp-bounces using -f |
| Message-ID: | <001d01c1bd54$100eea40$f3e0a0c8@rjo.virtua.com.br> |
| From: | "Pedro Izecksohn" <izecksohn AT yahoo DOT com> |
| To: | <djgpp AT delorie DOT com> |
| Subject: | NoEnd Loop. |
| Date: | Sun, 24 Feb 2002 13:55:19 -0300 |
| MIME-Version: | 1.0 |
| X-Priority: | 3 |
| X-MSMail-Priority: | Normal |
| X-Mailer: | Microsoft Outlook Express 6.00.2600.0000 |
| Disposition-Notification-To: | "Pedro Izecksohn" <izecksohn AT yahoo DOT com> |
| X-MimeOLE: | Produced By Microsoft MimeOLE V6.00.2600.0000 |
| Reply-To: | djgpp AT delorie DOT com |
Hi, When compiled, the code bellow works fine if you enter a number, but
if you enter a letter it enters in a noend loop. What is wrong with it ?
#include <stdio.h>
int main () {
int number=0;
while ( (number!=1) && (number!=2) ) {
printf("%s","1 = Encrypt. 2 = Decrypt. ? ");
scanf("%d",&number);
if ( (number!=1) && (number!=2) ) {
printf("%s","A wrong number was entered.\n");
} // Ends if of wrong number.
} // Ends while.
printf("%d",number);
return 0;
} // Ends main.
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |