Hi,
In one book about C programming in Chapter Disk Files I found this explanation:
"
The function call fclose() represents signal to OS (operating system) to "break" connection between program and the file and to release all resources that was needed to maintain this connection. After the file has been closed
OS automatically adds at the end of the file a special marker called EOF (end of file). EOF has special value that is OS dependent and that value cannot be value that might appear among internal data in the file.
"
I translated this as best as I can but I'm sure you'll understand.
I know that this EOF has nothing to do with EOF defined in stdio.h as (-1).
I have Win XP and wrote simple program to do some tests.
I located file Test.bin and in it's properties I found this:Code:#include <stdio.h>
int main()
{
int x=1,i;
FILE *fp;
fp=fopen("Test.bin","wb");
for(i=0;i<1024;i++)
fwrite(&x,sizeof(int),1,fp);
fclose(fp);
return 0;
}
size: 4,00 KB (4096 bytes)
size on disk 4,00 KB (4096 bytes)
I know that size of a cluster is 4,00 KB on my disk so my question is:
Is this sufficient to conclude that no special values are added in the file?
If it is (and I suppose it is) how files are stored and maintained by Windows(I mean that special EOF is not part of file)?
If file is bigger then 4 KB it occupies more than one cluster what structure Windows make to keep track of files?
I know these last two questions are not for C board but I hope you'll have an understanding and answer.
Thanks a lot!