33,311
社区成员
发帖
与我相关
我的任务
分享
int Worker::read(Worker * head)
{
ofstream infile;
infile.open("签到.txt", ios::app);
if (!infile)
{
return 0;
}
else
{
infile.close();
ifstream infile;
infile.open("签到.txt", ios::in);
while (!infile.eof())
{
Worker* newnode = new Worker;
infile >> newnode->Number;
if (newnode->Number.length() == 0)
{
delete newnode;
break;
}
infile >> newnode->Name;
infile >> newnode->sex;
infile >> newnode->age;
infile >> newnode->Number;
infile >> newnode->Phone;
if (newnode->start != NULL && newnode->end != NULL)
{
infile >> newnode->start;
infile >> newnode->end;
}
head->next = newnode;
head = head->next;
}
infile.close();
}
return 0;
}
void Worker::write(Worker * t)
{
ofstream outfile;
outfile.open("签到.txt", ios::out);
while (t->next != NULL)
{
outfile << t->next->Number << '\t';
outfile << t->next->Name << '\t';
outfile << t->next->sex << '\t';
outfile << t->next->age << '\t';
outfile << t->next->Phone << '\t';
outfile << t->start << '\t';
outfile << t->end << endl;
t = t->next;
}
outfile.close();
}
istream & operator>>(istream & input, Time *& t)
{
input >> t->year >> t->month >> t->day >> t->hour >> t->minute >> t->second;
return input;
// TODO: 在此处插入 return 语句
}