帮我改一下这个c++中的错误好吗

来源:百度知道 编辑:UC知道 时间:2024/05/28 04:48:38
int search(char *buf,int type,int command)
{ int number=0;
fstream outfile;
char ch;
char temp[30];
int i=0;
switch(type)
{
case 1: outfile.open("key.txt",ios::in);break;
case 2: outfile.open("bsf.txt",ios::in);break;
case 3: outfile.open("cs.txt",ios::in);break;
case 4: outfile.open("limit.txt",ios::in);break;
}
outfile.get(ch);
while(ch!=EOF){
while(ch!='\n')
{
temp[i++]=ch;
outfile.get(ch);
}
temp[i]='\0';
i=0;
number++;
if(strcmp(temp,buf)==0)
{
outfile.close();
return number; /*若找到,返回在相应表中的序号*/
}
else
outfile.get(ch);
} //结束外层while循环
if(command==1)
{
outfile.close( );
retu

哥们,把这几个头文件加进去
#include <fstream.h>
#include <iostream.h>
#include <string.h>

然后自己写个main函数就可以了

你的错误不在这段代码里,补充其它部分的代码

太长,也没格式
懒得看