home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / c / 18390 < prev    next >
Encoding:
Internet Message Format  |  1992-12-15  |  1.2 KB

  1. Path: sparky!uunet!munnari.oz.au!jabaru.cec.edu.au!csource!gateway
  2. From: John.Gibney@f386.n632.z3.fidonet.org (John Gibney)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: user input for inter
  5. Message-ID: <724433346.AA01307@csource.oz.au>
  6. Date: Sat, 12 Dec 1992 16:50:06
  7. Sender: gateway@csource.oz.au
  8. Lines: 28
  9.  
  10.  -=> Quoting Ejh@khonshu.colorado.edu to All <=-
  11.  
  12.  Ej> From: ejh@khonshu.colorado.edu (Edward J. Hartnett)
  13.  Ej> Organization: CIRES, University of Colorado
  14.  
  15. [... text deleted ...]
  16.  
  17.  Ej> One specific C question that I have is what is a good way to read the
  18.  Ej> user input. In FORTRAN I just READ(*,'(a)') whatever, but I hear that
  19.  Ej> I shouldn't use scanf in C. Is that right? What should I use instead?
  20.  
  21. For simplicity, I tend to use "gets()"...  you can then
  22. process it as a "string"or you can use the functions
  23. "atoi()" and/or "atof()" to turn it into numbers.  The
  24. formatting, et al with "scanf()" is a pain if the input
  25. formats don't EXACTLY match... as well as a common error for
  26. beginning C programmers is to leave out the "&" in "scanf()"
  27. calls.
  28.  
  29. Hope this is useful...
  30.  
  31.  
  32. John  :-)
  33.  
  34. ... The VMS MasterHarper!
  35. ___ Blue Wave/QWK v2.10
  36.  
  37.  * Origin: Eastern Mail Centre [PEP] OZ. +61-3-725-1621 (3:632/386)
  38.