C++大作业求助!
我的程序在用到新建利润文件时,就进入了死循环.又不知是哪出了问题!帮我看一下了,谢谢了!
#include "there.h "
#include "profit.h "
void Append(fstream f,fstream f1)
{
int choice;
goods g;
profit profi;
int key;
long num;
double b;
f.seekp(0,ios::end);
long posEnd=f.tellp();
f1.seekp(0,ios::end);
long posEnd1=f1.tellp();
cout < < "********* 入库登记 **********\n ";
while(1)
{
cout < < "请输入操作选择\n "
< < "1:新商品号\t "
< < "2:旧商品号\t "
< < "0:退出\n ";
cin> > choice;
switch(choice)
{
case 1:
{
int a;
long N;
char*s=new char[40];
double prof;
cout < < "商品号(QS),商品名,数量,
单价:\n? ";
cin> > a;
g.setQS(a);
cout < < "? ";
cin> > s;
g.setName(s);
cout < < "? ";
cin> > N;
g.setNumber(N);
cin> > prof;
g.setprice(prof);
f.write((char*)&g,sizeof(goods));
cout < < "write profit\n ";
cin> > b;
profi.setprofit(b);
f1.write((char*)&prof,sizeof(prof));
break;
};
case 2:
{
f.seekp(0,ios::beg);
cout < < "商品号(QS):\n? ";
cin> > key;
do
{
f.read((char*)&g,
sizeof(goods));
}while(g.getQS()!=key&&
f.tellp()!=posEnd);
if(g.getQS()==key)
{
cout < <
g.getQS() < < '\t ' < <g.getName() < < '\t '
< <g.getNumber() < < '\t '
< <g.getprice() < <endl;
cout < < "入库数量:\n? ";
cin> > num;
if(num> 0)
g.setNumber(g.getNumber()+num);
else
{
cout < <
"数量输入错误\n ";
continue;
}
f.seekp(
-long(sizeof(goods)),ios::cur);
f.write((char*)&g,
sizeof(goods));
cout < <
"现库存量:\t\t " < <
g.getNumber() < <endl;
}
else
cout < < "商品号输入错误\n ";
break;
}
case 0:return;
}
}
}
[解决办法]
#include "there.h "
#include "profit.h "
么会事啊
[解决办法]
?
[解决办法]
自己找到错误,然后提出问题,这样才能有针对性的帮你啊,这样全copy上来,有几个有那么多时间帮你看完,
[解决办法]
类的文件不写出来,怎么看啊?