From: Sinan_Unur AT mail DOT com (A. Sinan Unur) Newsgroups: comp.os.msdos.djgpp Subject: Re: Getchar problems in while() loop. Date: 22 May 2000 20:30:52 GMT Organization: Cornell University Lines: 54 Sender: verified_for_usenet AT cornell DOT edu (asu1 on 128.253.251.163) Message-ID: <8F3CA824FASINANUNUR@132.236.56.8> References: <39298E3C DOT 99DCB2A1 AT mail DOT owc DOT net> NNTP-Posting-Host: 128.253.251.163 X-Trace: news01.cit.cornell.edu 959027452 26155 128.253.251.163 (22 May 2000 20:30:52 GMT) X-Complaints-To: usenet AT news01 DOT cit DOT cornell DOT edu NNTP-Posting-Date: 22 May 2000 20:30:52 GMT User-Agent: Xnews/03.04.11 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com djgpp AT delorie DOT com (2711) wrote in <39298E3C DOT 99DCB2A1 AT mail DOT owc DOT net>: >Hey, thank you for reading my message, I'm having problems with a little >educational program I wrote, >The magic number is obviously five, but when it is entered, like any >other value, > >guess the magic number *beeep* >guess the magic number *beeep* > >is displayed. > >#include > >void main(void) please see question 1.25b in the comp.lang.c faq available at http://www.faqs.org/faqs/C-faq/faq/. >{ >int stop; > > while ((stop=getchar())!= 5) > { > printf("Guess the magic number\n\a"); > stop=getchar(); > } >} > the following would do something sorta good enough: #include int main(void) { while( getchar() != '5' ) puts("Guess the magic number:"); return 0; } however, the correct prompt in this case is "Guess the magic character", not magic number. for a simple example of parsing numbers typed on the command line, you can take a look at http://unur.com/howto/c-examples.html. hth. Sinan. -- mailto:Sinan_Unur AT mail DOT com http://unur.com/sinan/