home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / c / 16023 < prev    next >
Encoding:
Internet Message Format  |  1992-11-05  |  1.3 KB

  1. Path: sparky!uunet!inmos!bra.isnet.inmos.co.uk!svrobins
  2. From: svrobins@bra.isnet.inmos.co.uk (Paul Robins)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: fputs question.
  5. Message-ID: <1992Nov5.140208.63@bra.isnet.inmos.co.uk>
  6. Date: 5 Nov 92 14:02:08 GMT
  7. References: <1d9e4mINN8hn@rodan.UU.NET>
  8. Organization: Inmos Ltd
  9. Lines: 33
  10.  
  11. In article <1d9e4mINN8hn@rodan.UU.NET>, 
  12. smm@uunet.uu.net (Steve Mansfield) writes:
  13. > I'm working on a program, and for some reason this little chunk of code:
  14. > receive_link()
  15. > {
  16. >    int i;
  17. >    FILE *outstuff;
  18. >    char segment[30];
  19. >    outstuff = fopen("o","w");
  20. >    while(read(linkpipe[0],segment,30) != 0)
  21. >       fputs(segment,outstuff);
  22. >    close(outstuff);
  23.      ^^^^
  24. try fclose(outstuff);
  25.  
  26. >    close(linkpipe);
  27. > }
  28. > doesn't seem to want to write to file "o".  When I replace the fputs line
  29.  
  30. fclose() flushes any unwritten data for the stream before closing. close()
  31. may not do that. I think this varies between machines/implementations of
  32. the standard libs, but using fclose() is the safe way to ensure any buffered
  33. data is written.
  34.  
  35. Paul Robins.
  36. _______________________________________________________________________
  37. email: svrobins@isnet.inmos.co.uk | 
  38. phone: (UK) 0633 810121           |     gave up the .sigs years ago
  39. fax  : (UK) 0633 810820           |
  40. -----------------------------------------------------------------------
  41.