File Manipulation Functions in C

Question: What are File Manipulation Functions in C Language

Answer: Functions which manipulate files without performing I/O with them are called file manipulation functions. They are prototyped below

    int remove(char const *filename);
    int rename(char const *oldname, char const *newname);

‘remove()’ function can be used to explicitly close/delete a file specified by argument. If the specified file is open while remove() was called, behaviour is implementation defined. ‘rename()’ function can be called to change the name of a file from oldname to newname. If the file with newname is already existing while ‘rename()’ was called, behaviour is implementation defined. Both the functions return ZERO when succeed and non-zero value when they fail. If ‘rename()’ fails, file with original name is yet accessible.

For example, for an existing file “hello.txt”,

    rename("hello.txt", "byebye.txt");

Sanfoundry Global Education & Learning Series – 1000 C Tutorials.

If you wish to look at all C Tutorials, go to C Tutorials.

If you find any mistake above, kindly email to [email protected]

Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.