c - How to use fread correctly? -
i've seen 2 ways of providing size of file fread
.
if lets have char array data
, file
pointer , filesize
size of file in bytes first is:
fread(data, 1, filesize, file);
and second:
fread(data, filesize, 1, file);
my question is, there difference between 2 lines of code?
, line of code more "correct".
also, i'm assuming 1
in 2 lines of code means sizeof(char)
, correct?
argument 2: size of each member
argument 3: number of objects want read
now question:
is there difference between 2 lines of code?
fread(data, 1, filesize, file);
reads filesize
objects pointed data size of each object 1 byte. if less filesize
bytes read, read partially.
fread(data, filesize, 1, file);
reads 1
object pointed data size of object filesize
bytes. if less filesize
bytes available, none read.
do whatever requirement of program.
Comments
Post a Comment