Copying and overwriting a file using file descriptor

Hi ,

i have two basic requirement on linux platform . I am using C language to do this .
1) copying one file to another (assuming i know their file descriptors)
2) Overwriting a file using it file descriptor .

Please guide.

regards
Aki

Is this homework?

We have a homework forum for homework questions.

The simple answer is to call fdopen(file_descr, mode). File descriptors are only valid within a process, or in a child process. For linux check out sendfile.