C程序的翻译

来源:百度知道 编辑:UC知道 时间:2024/05/23 18:35:51
void lending::borrow()
{
a:
ifstream fin;
int flag=0,b,length;
char str[20];
char f[200];char g[200];
fin.open("f1.dat");
if(!fin)
{
cout<<"Open f1.dat error....."<<endl;
exit(1);
}
while(1)
{
cout<<"请输入你要借的书名:";
cin>>str;
strcat(str,"\t");
length=strlen(str);
cout<<"------------------------------------------------"<<endl;
while(fin.getline(f,199))
{
strcpy(g,f);
if(strncmp(str,f,length)==0)
{
flag=1;
break;
}
}
if(flag==1)
{
cout<<"借书成功,你借的书已经输入你的文件:"<<'\n';
cout<<"---------------------------------------------"<<endl;
cout<<"书名"<<'\t'<<"书号"<<'\t'<<"作者"<<'

从dat(一个类似数据库的文件)读数据,如果有异常显示错误消息。
成功读入数据后,整体功能是用来借书的。并且当借书操作有成功和失败两个状态,成功的话将写入f3.dat(基本上是将借书信息保存入数据库文件)失败就结束了

没什么可翻译的啊,程序代码写的很清楚嘛……,不知道楼主想要什么信息……