Simple question,
When i use fread:
fread(ArrayA, sizeof(Reg), sizeBlock, fp);
My file pointer, fp is moved ahead?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Answer: Yes, the position of the file pointer is updated automatically after the read operation, so that successive
fread()functions read successive file records.Clarification:
fread()is a block oriented function. The standard prototype is:The function reads from the stream pointed to by
streamand places the bytes read into the array pointed to byptr, It will stop reading when any of the following conditions are true:limitelements of sizesize, orfread()gives you as much control asfgetc(), and has the advantage of being able to read more than one character in a single I/O operation. In fact, memory permitting, you can read the entire file into an array and do all of your processing in memory. This has significant performance advantages.fread()is often used to read fixed-length data records directly into structs, but you can use it to read any file. It’s my personal choice for reading most disk files.