我导入一个输出一个是正常的,导入全部后输出变乱码“屯屯屯”之类的
void load_list(Linklist List)
{
int cnt3 = 0, cnt4 = 0;
ifstream load("test.xls");
if (load.is_open())
{
cout << endl << "载入文件成功" << endl;
cout << "新增人员信息如下:" << endl;
char buffer[256] = { 0 };
while (load >> buffer)
{
LNode* p = new LNode;
if (cnt4 % 4 == 0)
{
insert_list(List, p);//插入节点
cnt++;
}
cnt4++;
if (0 == cnt3)
{
strcpy(p->name, buffer);
cout << "-------------------" << endl;
cout << "姓名:" << p->name << endl;
cnt3 = 1;
}
else if (1 == cnt3)
{
strcpy(p->num, buffer);
cout << "学号:" << p->num << endl;
cnt3 = 2;
}
else if (2 == cnt3)
{
strcpy(p->tele_num, buffer);
cout << "电话号码:" << p->tele_num << endl;
cnt3 = 3;
}
else if (3 == cnt3)
{
strcpy(p->address, buffer);
cout << "地址:" << p->address << endl;
cout << "-------------------" << endl;
cnt3 = 0;
}
}
load.close();
}
else
{
cout << "打开文件失败" << endl;
return;
}
}
void insert_list(Linklist& List, LNode* node)
{
node->next = List->next;
List->next = node;
}