The rename () function modifies and moves the names of files or folders (files and folders in linux cannot be renamed. In the example of the following edge, move the file or folder named 1 under the current file to the 2 file or folder under the leeTest file of the previous level. The premise is that the leeTest file cannot contain 2 files or folders. Otherwise, the program fails to run.
[Cpp]
# Include <stdio. h>
Int main ()
{
Printf ("rename \ n ");
Int flag = rename ("./1", "../leeTest/2 ");
Printf ("% d \ n", flag );
Return 0;
} Www.2cto.com
The remove () function only deletes the specified path file. remove () deletes a name from the filesystem. It callunlink () for files, and rmdir () for directories.
[Cpp]
# Include <stdio. h>
Int main ()
{
Remove ("./ftw"); // Delete the ftw file under the current file
Return 0;
}
Author: Leeboy_Wang