home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!inmos!bra.isnet.inmos.co.uk!svrobins
- From: svrobins@bra.isnet.inmos.co.uk (Paul Robins)
- Newsgroups: comp.lang.c
- Subject: Re: fputs question.
- Message-ID: <1992Nov5.140208.63@bra.isnet.inmos.co.uk>
- Date: 5 Nov 92 14:02:08 GMT
- References: <1d9e4mINN8hn@rodan.UU.NET>
- Organization: Inmos Ltd
- Lines: 33
-
- In article <1d9e4mINN8hn@rodan.UU.NET>,
- smm@uunet.uu.net (Steve Mansfield) writes:
- > I'm working on a program, and for some reason this little chunk of code:
- >
- > receive_link()
- > {
- > int i;
- > FILE *outstuff;
- > char segment[30];
- >
- > outstuff = fopen("o","w");
- > while(read(linkpipe[0],segment,30) != 0)
- > fputs(segment,outstuff);
- > close(outstuff);
- ^^^^
- try fclose(outstuff);
-
- > close(linkpipe);
- > }
- > doesn't seem to want to write to file "o". When I replace the fputs line
- >
-
- fclose() flushes any unwritten data for the stream before closing. close()
- may not do that. I think this varies between machines/implementations of
- the standard libs, but using fclose() is the safe way to ensure any buffered
- data is written.
-
- Paul Robins.
- _______________________________________________________________________
- email: svrobins@isnet.inmos.co.uk |
- phone: (UK) 0633 810121 | gave up the .sigs years ago
- fax : (UK) 0633 810820 |
- -----------------------------------------------------------------------
-