why i asked this question ?..u know i found this question about c programng interview and it was that :
(9)What will be output of following program?
Code:
#include<stdio.h>
int main(){
char c;
FILE *fp;
fp=fopen("test.txt","r");
printf("\n %x",fp->flags);
fp=fopen("test.txt","rb+");
printf("\n %x",fp->flags);
fclose(fp);
return 0;
}
Output: 5 47
Explanation:
In stdio.h there are flag status macros which are:
NAME Meaning Value (In hexadecimal)_F_RDWR Read and write 0X0003
_F_READ Read-only file 0X0001
_F_WRIT Write-only file 0X0002
_F_BUF Malloc'ed buffer data 0X0004
_F_LBUF Line-buffered file 0X0008
_F_ERR Error indicator 0X0010
_F_EOF EOF indicator 0X0020
_F_BIN Binary file indicator 0X0040
_F_IN Data is incoming 0X0080
_F_OUT Data is outgoing 0X00100
_F_TERM File is a terminal 0X00200
and i definitely didn't understand this and for that i asked what it means every member (flags and_ptr and ...so on).