L.elem = new Book[MAXSIZE]; //C++
L.elem = (Book*)malloc(MAXSIZE * sizeof(Book)); //C
cout << "1.初始化n"; //C++
printf("1.初始化n"); //C
cin >> choose;
scanf("%d",&choose);
fstream file;
file.open("SqStack.txt");
if (!file)
{
cout << "错误!未找到文件!" << endl;
exit(ERROR);
}
file >> head_1 >> head_2 >> head_3;
while (!file.eof())
{
file >> L.elem[i].id >> L.elem[i].name >> L.elem[i].price;
i++;
}
file.close();
FILE *fp;
fp = fopen("SqStack.txt","r+");
if (fp==NULL)
{
printf("错误!未找到文件!n" );
exit(ERROR);
}
while (!feof(fp))
{
fgets(buf, 256, fp);
s = buf;
sscanf(s, "%s%s%lf", &L.elem[i].id, &L.elem[i].name, &L.elem[i].price);
i++;
}
fclose(fp);