Path: utzoo!utgpu!attcan!uunet!seismo!sundc!pitstop!sun!amdcad!ames!haven!mimsy!jds From: jds@mimsy.UUCP (James da Silva) Newsgroups: comp.unix.questions Subject: Re: C/UNIX low level I/O Keywords: C, I/O, open, fopen Message-ID: <14307@mimsy.UUCP> Date: 2 Nov 88 16:05:25 GMT References: <6695@pyr.gatech.EDU> Reply-To: jds@mimsy.umd.edu (James da Silva) Organization: University of Maryland, Department of Computer Science Lines: 24 In article <6695@pyr.gatech.EDU> david@pyr.gatech.edu (David Brown) writes: > > ... But this ay, I do a separate 'write' for every word in the > list, and a 'write' for the spaces between and the newlines. Like this: > [ pseudocode showing writes for each word and space, then for the newline ] > > My question: is there a better way to do this? I've thought of using > higher-level I/O routines like fprintf, but I think they would be > less efficient. But less efficient than what I'm doing now? If you don't need the formatting capabilities of fprintf, try using fputs. I think you will see a significant speed boost because the stdio library buffers your output rather than doing a system call for each word. You can get even more juice by buffering it yourself, since you don't have to be as general as stdio does. But then you have to be sure to pick a good buffer size for your system... - Jaime ---------------------------------------------------------------------- path: uunet!mimsy!jds James da Silva domain: jds@mimsy.umd.edu