home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / c / 19263 < prev    next >
Encoding:
Text File  |  1993-01-05  |  1.2 KB  |  37 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!gatech!destroyer!news.iastate.edu!pv0321.vincent.iastate.edu!dschmitz
  3. From: dschmitz@iastate.edu (Daniel C Schmitz)
  4. Subject: Re: ** Ack! Help again! **
  5. Message-ID: <dschmitz.726261452@pv0321.vincent.iastate.edu>
  6. Sender: news@news.iastate.edu (USENET News System)
  7. Organization: Iowa State University, Ames IA
  8. References: <kaNTwB1w165w@tradent.wimsey.bc.ca>
  9. Date: Tue, 5 Jan 1993 19:17:32 GMT
  10. Lines: 25
  11.  
  12. In <kaNTwB1w165w@tradent.wimsey.bc.ca> lord@tradent.wimsey.bc.ca (Jason Cooper) writes:
  13.  
  14. >time I use scanf or gets, and I ask for more than one input of a string 
  15. >in a row, like this:
  16. >gets(string1)
  17. >gets(string2)
  18. >or however that works (the point being they are seperate lines), C will 
  19. >skip some of the inputs for apparently no reason at all. 
  20.  
  21. I have often had problems with scanf followed by a gets.  The first gets
  22. that follows any series scanf's always returns an empty string.
  23. A hack that has worked for me on some systems is to put a dummy gets between
  24. scanf's and gets's.
  25.  
  26. scanf(...)
  27. scanf(...)
  28. gets(..)    /* this is a dummy, to fix problems that I've experienced */
  29. get(...)    /* legitimate gets, use the results */
  30. scanf(...)
  31. gets(...)    /* dummy */
  32. gets(...)    /* useful value */
  33.  
  34. dschmitz
  35. dschmitz@iastate.edu
  36.  
  37.