- Why variables can not be declared in a switch statement just after labels?
- Cross Compile C/C++ based programs and Run them on Android Smart-Phones
- Whether should i use processes or threads in Linux?
- Short-circuiting in C Programming Expressions………….!!!
- Confusion with megabytes, 1 megabyte is 1 million bytes or 1024 * 1024 (1048576) bytes?
After having 1 year of experience in c programming when someone has asked this to me i was surprised that why i dont know this…!!
Well when i will going to interview someone in someday this would be my 1st question to him/her…!!!
File Descriptor :
“A file descriptor is a low-level integer “handle” used to identify an opened file (or socket, or whatever) at the kernel level, in Linux and other Unix-like systems.”
int fd; fd = open(path, O_CREAT | O_RDONLY, 0644); close(fd);
This way you are using that is file-descriptor. In short, file-descriptor is
- Low/Kernel level handler
- passe to read() and write() of UNIX System Calls
- Doesn’t include buffering and such features
- Less portable and lacks efficiency
- It’s some what OS specific so its not part of standard c programming language.
File Pointer :
“A FILE pointer is a C standard library-level construct, used to represent a file. The FILE wraps the file descriptor, and adds buffering and other features to make I/O easier.”
FILE *fp = fopen("mr32.txr","r");
When you write this then you are using file pointer. file pointer is
- It is high level interface
- Passed to fread() and fwrite() functions
- Includes buffering,error indication and EOF detection,etc.
- Provides higher portability and efficiency.
- It’s part of standard c programming language.