重命名文件
#include<iostream>
#include<fstream>
#include<string>
#include <Windows.h>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
char MAC[256] = "123456789";
int Average_power = 10;
int main()
{
ofstream OpenFile("Log.txt");
if (OpenFile.fail())
{
cout << "打开文件错误!" << endl;
exit(0);
}
OpenFile << "MAC:";
OpenFile << MAC << endl;
OpenFile << "Power:";
OpenFile << Average_power << endl;
OpenFile.close();
char file[256];
sprintf(file, "rm -rf 123.txt");
system(file);
//sprintf(file, "move %s 123.txt", "Log.txt");
sprintf(file, "rename %s 123.txt", "Log.txt");
system(file);
//system("pause");
return 0;
}

浙公网安备 33010602011771号