Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!think.com!paperboy!hsdndev!husc6!unix!mxmora From: mxmora@unix.SRI.COM (Matt Mora) Newsgroups: comp.sys.mac.programmer Subject: Simple C question Message-ID: <23112@unix.SRI.COM> Date: 11 Apr 91 23:17:58 GMT Reply-To: mxmora@sri-unix.sri.com (Matt Mora) Organization: SRI International, Menlo Park, CA Lines: 36 To all you C guru's out there HELP! I must be missing something totally obvious but the code below is not working as expected. :-( scanf is supposed to return the number of successful conversions correct? In the code below whether I type in a number or a string of characters, test always equals one. Shouldn't test become zero when a non numeric input is typed in? This happens in think C 4.0.2 while ((test=scanf("%d",&thenumber))!=EOF) { printf("The Number %d Test %d \n",thenumber,test); printf("Enter a number "); thenumber=0; fflush(stdin); } Also when I compiled this on my unix machine after I typed in a string of characters it went into an endless loop not allowing me to enter in another value. It just kept printing "The Number ..." What the heck am I doing wrong. Thanks Matt -- ___________________________________________________________ Matthew Mora | my Mac Matt_Mora@sri.com SRI International | my unix mxmora@unix.sri.com ___________________________________________________________