Help with fread() and fwrite()

Shiping Zhang ping at cubmol.BIO.COLUMBIA.EDU
Sun Aug 20 03:00:55 AEST 1989


In article <2800 at wasatch.utah.edu> u-tholly at 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



More information about the Comp.lang.c mailing list