#include <iostream> #include <cstdio> int main() { const char* oldName = "oldname.txt"; const char* newName = "newname.txt"; if (rename(oldName, newName) == 0) { std::cout << "File renamed successfully." << std::endl; } else { std::cerr << "Error renaming file." << std::endl; } return 0; }