Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!munnari.oz.au!bruce!trlluna!rhea.trl.oz.au!aduncan From: aduncan@rhea.trl.oz.au (Allan Duncan) Newsgroups: comp.sys.amiga.tech Subject: Re: I/O of complex data structures in C Message-ID: <2057@trlluna.trl.oz> Date: 9 Aug 90 22:53:57 GMT References: Sender: root@trlluna.trl.oz Lines: 31 From article , by dillon@overload.Berkeley.CA.US (Matthew Dillon): > fwrite(ptr, blockSize, numBlocks, fi); > const void *ptr; pointer into memory, fwrite does not know or > care what the pointer is actually pointing > to! const means the memory is not modified > by fwrite() (obvious). > int blockSize; fwrite writes blockSize * numBlocks bytes > int numBlocks; of data from the memory location given by > 'ptr' to the file, no interpretation of the > data is done. Where did you find this? It doesn't exist in K&R. From V7 UNIX Programmer's Manual : fwrite( ptr, sizeof( *ptr ), nitems, stream ) fwrite appends at most nitems of data of the type *ptr beginning at ptr to the named output stream. It returns the number of items actually written. So you can see that the two are _not_ the same. In detail, you either write an item, or you don't - no half written items are permitted. I looked at the source for the Manx call, and it uses two for loops to call fputc(), not multiply block by items, then one loop. Allan Duncan ACSnet a.duncan@trl.oz (03) 541 6708 ARPA a.duncan%trl.oz.au@uunet.uu.net UUCP {uunet,hplabs,ukc}!munnari!trl.oz.au!a.duncan Telecom Research Labs, PO Box 249, Clayton, Victoria, 3168, Australia.