In the below snippet,Rewind() wraps up the file but still the no of records exceed the MAX value set.
if(no_of_msg_records >= MAX)
{
rewind(fp_msg);
no_of_msg_records=0;
}
ie the no_of_msg_records in the file exceeds MAX value.

how was the file opened? The file needs to be opened for either reading only or both reading and writing, such as in the example here

with "w+" mode...

Where is the value for no_of_msg_records being set ?

Are you sure no_of_msg_records contains the correct value before the if statement ?

yes everytime a write operation is performed,this value is incremented.

Just to clarify the control is going inside the if block, the rewind is working properly but the assignment operation is failing ?

If there is an issue with rewind ... try fseek

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.