home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / c / 13498 < prev    next >
Encoding:
Text File  |  1992-09-10  |  1.1 KB  |  37 lines

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!sun-barr!sh.wide!wnoc-tyo-news!scslwide!wsgw!wsservra!sakamoto
  2. From: sakamoto@sm.sony.co.jp (Tomohiko Sakamoto)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Dropping a n from a fprintf()
  5. Message-ID: <1992Sep11.062806.29139@sm.sony.co.jp>
  6. Date: 11 Sep 92 06:28:06 GMT
  7. References: <1992Sep11.052108.26159@ra.msstate.edu>
  8. Sender: news@sm.sony.co.jp (Usenet News System)
  9. Reply-To: sakamoto@sm.sony.co.jp
  10. Organization: Workstation Div., Supermicro Systems Group, Sony Corporation
  11. Lines: 23
  12. Nntp-Posting-Host: sak3
  13.  
  14. In article <1992Sep11.052108.26159@ra.msstate.edu>,
  15.         cee1@ra.msstate.edu (Charles Evans) says:
  16. > fscanf(fp1,"%s",item)  .. seems to be giving EVERYTIME a Segmentation
  17. > Fault (UNIX) in that line. so we went to fgets.. what can I do to get
  18. > it all on one line.. thanks
  19.  
  20. How about this?
  21.  
  22. /**************************************************************/
  23. #include <stdio.h>
  24.  
  25. main()
  26. {
  27.     FILE *fp1 = stdin;
  28.     FILE *fp2 = stdout;
  29.     char item[20];
  30.  
  31.     while (fscanf(fp1, "%19s", item) == 1)
  32.         fprintf(fp2, "I found a %s in my pockect.\n", item);
  33. }
  34.  
  35. --
  36. T. Sakamoto
  37.