home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!sun-barr!sh.wide!wnoc-tyo-news!scslwide!wsgw!wsservra!sakamoto
- From: sakamoto@sm.sony.co.jp (Tomohiko Sakamoto)
- Newsgroups: comp.lang.c
- Subject: Re: Dropping a n from a fprintf()
- Message-ID: <1992Sep11.062806.29139@sm.sony.co.jp>
- Date: 11 Sep 92 06:28:06 GMT
- References: <1992Sep11.052108.26159@ra.msstate.edu>
- Sender: news@sm.sony.co.jp (Usenet News System)
- Reply-To: sakamoto@sm.sony.co.jp
- Organization: Workstation Div., Supermicro Systems Group, Sony Corporation
- Lines: 23
- Nntp-Posting-Host: sak3
-
- In article <1992Sep11.052108.26159@ra.msstate.edu>,
- cee1@ra.msstate.edu (Charles Evans) says:
- > fscanf(fp1,"%s",item) .. seems to be giving EVERYTIME a Segmentation
- > Fault (UNIX) in that line. so we went to fgets.. what can I do to get
- > it all on one line.. thanks
-
- How about this?
-
- /**************************************************************/
- #include <stdio.h>
-
- main()
- {
- FILE *fp1 = stdin;
- FILE *fp2 = stdout;
- char item[20];
-
- while (fscanf(fp1, "%19s", item) == 1)
- fprintf(fp2, "I found a %s in my pockect.\n", item);
- }
-
- --
- T. Sakamoto
-