Can anybody tell me what are file descriptors in C?? I searched the net but can't clear my concepts!!!

Recommended Answers

All 4 Replies

In UNIX-like systems, a file descriptor is a small integer associated with an open file stream. You can use procedures like read and write to read and write to a particular file stream, and in order to do this, you need to provide the file descriptor for the open file you want written to. The procedure open is used to open files, and it returns the integer that should be used as the file descriptor (or in case of error, returns -1).

The standard C library, with procedures like fopen, fread, and fwrite uses 'FILE pointers', pointers of type FILE*, to refer to open files.

I don't know what Windows uses for OS-specific input/output.

MS-Windows specific -- calls them file handles, otherwise the concept is the same as stated previously by Rashakil.

Thanks Rakshali for ur worthy reply.

Hi himanjim,
These functions(read,write,close,...) are called system calls which are kernel-level file manipulation.
Inorder to get information on linux system calls,search google for

Advanced Linux Programming

.
It would be found in PDF format easily.
I have a project for this purpose.Tell me if you want the source code.

Good luck.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.