What are File Manipulation Functions in C Language
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");