Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

C++ rename function

#include <iostream>
#include <cstdio>

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;
}
Source by www.programiz.com #
 
PREVIOUS NEXT
Tagged: #rename #function
ADD COMMENT
Topic
Name
5+8 =