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

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -