📜  C++ 重命名函数 - C++ 代码示例

📅  最后修改于: 2022-03-11 14:44:47.345000             🧑  作者: Mango

代码示例1
#include 
#include 

using namespace std;

int main()
{
    char oldname[] = "file_old.txt";
    char newname[] = "file_new.txt";
    
    /*    Deletes the file if exists */
    if (rename(oldname, newname) != 0)
        perror("Error renaming file");
    else
        cout << "File renamed successfully";
    
    return 0;
}