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

Popular posts from this blog

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -