C编程高手进来帮下小弟,感激不尽!

2025-01-20 01:50:09
推荐回答(2个)
回答1:

记时器 % 10==0时,触发依次保存函数
这是别的程序的保存到txt文件的一些函数
看看这思路能不能作出来

class DBOperate
{
public:
string Employeename;
long Employeenum;
char Employeesex;
int Employeeage;

static long EmployeeMaxNum;
static float EmployeeBasePay;

void WriteIn(int iflag);
void ReadOut();
void RefreshMaxNum(int iflag); //i=1 or -1 or 0
};
ReadOut() //数据操作函数 读出
{
ifstream myf("Employee.txt");
Employee e;
DBOperate s;
int MN;
MN = e.MaxNum();
for(int i=0 ;i{
myf>>s.Employeenum>>s.Employeename>>s.Employeesex>>s.Employeeage;
Enum[i] = s.Employeenum;
Ename[i] = s.Employeename;
Esex[i] = s.Employeesex;
Eage[i] = s.Employeeage;
}
myf.close();
}
WriteIn(int iflag) //数据操作函数 写入
{
DBOperate s;
s.RefreshMaxNum(iflag);
ofstream myf("Employee.txt");
Employee e;
int MN;
MN = e.MaxNum();
for(int i=0;i{
myf<}
myf.close();
return;
}

回答2:

用一个时间函数!!获取系统时间!!这样每当10秒就可以修改文件内容了!!