C
chat
Hi,
I know that text file ended with EOF mark but there is no mark for
binary file.
So, the problem is how do we know the end of binary file is reach?
This code can tell us when the end of file is reach
int ch;
FILE *fp;
fp = fopen("filename","rb");
if(fp != NULL) {
while((ch = getc(fp)) != EOF) {
/* your code */
}
}
My question is , since there is no ending mark up for binary file, why
does the code above work?
also, why does built-in function feof(fp) know where is end-of-file?
thank you for all discussions.
chat watchara
I know that text file ended with EOF mark but there is no mark for
binary file.
So, the problem is how do we know the end of binary file is reach?
This code can tell us when the end of file is reach
int ch;
FILE *fp;
fp = fopen("filename","rb");
if(fp != NULL) {
while((ch = getc(fp)) != EOF) {
/* your code */
}
}
My question is , since there is no ending mark up for binary file, why
does the code above work?
also, why does built-in function feof(fp) know where is end-of-file?
thank you for all discussions.
chat watchara