Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!columbia!cubmol!ping From: ping@cubmol.BIO.COLUMBIA.EDU (Shiping Zhang) Newsgroups: comp.lang.c Subject: Re: Help with fread() and fwrite() Keywords: fread fwrite Message-ID: <323@cubmol.BIO.COLUMBIA.EDU> Date: 19 Aug 89 17:00:55 GMT References: <2800@wasatch.utah.edu> Reply-To: ping@cubmol.UUCP (Shiping Zhang) Distribution: na Organization: Dept. of Biology, Columbia Univ., New York, NY Lines: 17 In article <2800@wasatch.utah.edu> u-tholly@wasatch.utah.edu (Troy Holly) writes: >I used fwrite() to write an array and the length of the array to disk. When >I used fread() to read the same data, only the first element of the array and >the integer representing the length had the right value. The code was >compiled with Microsoft C 5.1, and looks something like this: >What am I doing wrong? [......] >Troy One thing I can see immediately to be wrong is the way malloc() is used. malloc() returns a point to char. To assign it to a point to float, proper casting must be made. -ping