Saturday, 28 September 2013

two consecutive fwrites on same file

two consecutive fwrites on same file

i have read all sources and I tried to understand why this code is giving
such output, but i couldn't understand. Please if someone could give me
specific answers....
#include<stdio.h>
int main()
{
FILE *fp1;
FILE *fp2;
fp1=fopen("abc","w");
fp2=fopen("abc","w");
fwrite("BASIC",1,5,fp1);
fwrite("BBBBB CONCEPTS",1,14,fp2);
return 0;
}
The output is BASIC CONCEPTS when i opened the file "abc". Why has second
fwrite not overwritten the contents of file "abc"? the expected output
should be BBBBB CONCEPTS

No comments:

Post a Comment