Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!samsung!spool.mu.edu!uwm.edu!bionet!agate!violet.berkeley.edu!lindahl From: lindahl@violet.berkeley.edu (Ken Lindahl 642-0866) Newsgroups: comp.sys.mac.programmer Subject: Re: Simple C question Message-ID: <1991Apr15.184826.25911@agate.berkeley.edu> Date: 15 Apr 91 18:48:26 GMT References: <23112@unix.SRI.COM> <41210@cup.portal.com> Sender: usenet@agate.berkeley.edu (USENET Administrator) Organization: University of California, Berkeley Lines: 18 In article <41210@cup.portal.com> gort@cup.portal.com (george d harrington) writes: >matt mora (mxmora@unix.sri.com) writes: ... >>while ((test=scanf("%d",&thenumber))!=EOF) ... >If what you really want to do is exit the loop when you enter a non- >numeric, change it to > while ( scanf("%d",theNumber) != 1) Actually, to exit the loop when a non-number is scanf'ed: while ( scanf("%d",&theNumber) == 1) ^^ Ken Lindahl lindahl@violet.berkeley.edu Advanced Technology Planning, Information Systems and Technology University of California at Berkeley