Path: utzoo!attcan!uunet!lll-winken!lll-lcc!ames!nrl-cmf!cmcl2!rutgers!att!whuts!homxb!mr From: mr@homxb.UUCP (mark) Newsgroups: comp.unix.questions Subject: Re: C/UNIX low level I/O Keywords: C, I/O, open, fopen Message-ID: <2368@homxb.UUCP> Date: 2 Nov 88 19:10:48 GMT References: <6695@pyr.gatech.EDU> Organization: AT&T Lines: 30 In article <6695@pyr.gatech.EDU>, david@pyr.gatech.EDU (David Brown) writes: # # Hi, NetLanders. I've a small C/UNIX problem. I need to do a bunch of # small write's to a file. I need to know the quickest way to do it. # I've got a linked list of 'words' that I need written to a file in a # humanly readable and understandable fashion. But it needs to take as # little time as possible. For instance, the way I have it now, I use # write(2). 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: # # while (list ~empty){ # write word # write space # } # write 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? You could make a buffer, say 512 chars. Fill the buffer and then 'write' the entire buffer out. (as long as this is not an interactive application). If you want you can use 'sprintf(3)' to compile a string which would then be attached to the buffer with strcat or your own routine. # Thanks, # David Brown mark homxb!mr