What are File Manipulation Functions in C Language

Taylor Emma
1 Min Read
Disclosure: This website may contain affiliate links, which means I may earn a commission if you click on the link and make a purchase. I only recommend products or services that I personally use and believe will add value to my readers. Your support is appreciated!

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”,

    remove(“hello.txt”);

    rename(“hello.txt”, “byebye.txt”);

Share This Article
A senior editor for The Mars that left the company to join the team of SenseCentral as a news editor and content creator. An artist by nature who enjoys video games, guitars, action figures, cooking, painting, drawing and good music.
Leave a review