cannot convert parameter 1 from 'char' to 'const char *'这是哪里错了呢
#include<iostream.h>#include<fstream.h>#include<string.h>voidlook();voidlook1();voidl...
#include<iostream.h>
#include<fstream.h>
#include<string.h>
void look();
void look1();
void look2();
void look3();
class student{
public:
int number;
char name[10];
char sex[9];
int banji;
double grade;
};
void look()
{
cout<<"按学号查询请按1:"<<endl;
cout<<"按姓名查询请按2:"<<endl;
cout<<"按成绩查询请按3:"<<endl;
int i;
char way(i);
cin>>i;
while(strcmp(way,"1")!=0&&strcmp(way,"2")!=0&&strcmp(way,"3")!=0&&strcmp(way,"4")!=0)
{
cout<<"***输入错误***请重新输入:";
cin>>way;
}
if(strcmp(way,"1")==0)
{
look1();
}
if(strcmp(way,"2")==0)
{
look2();
}
if(strcmp(way,"3")==0)
{
look3();
}
void look1()
{
int max;
ifstream fin1("max.dat");
if(!fin1)
{
cout<<"打开文件失败!";
exit(1);
}
fin1>>max;
ifstream fin3("student.dat");
if(!fin3)
{
cout<<"open error!"<<endl;
exit(1);
}
for(int i=0;i<max;i++)
{
fin3>>stu[i].number>>stu[i].name>>stu[i].sex>>stu[i].banji>>stu[i].grade;
}
cout<<"请输入学生学号:";
int num;
cin>>num;
cout<<"查询结果"<<endl;
int bianbie2=0;
for(int j=0;j<max;j++)
{
if(stu[j].number==num)
{
++bianbie2;
cout<<"学号:"<<stu[j].number<<"姓名:"<<stu[j].name<<"性别:"<<stu[j].sex<<"班级:"<<stu[j].banji<<"成绩:"<<stu[j].grade<<endl;
}
}
if(bianbie2==0)
{
cout<<"没有你查询的同学"<<endl;
}
fin3.close();
} 展开
#include<fstream.h>
#include<string.h>
void look();
void look1();
void look2();
void look3();
class student{
public:
int number;
char name[10];
char sex[9];
int banji;
double grade;
};
void look()
{
cout<<"按学号查询请按1:"<<endl;
cout<<"按姓名查询请按2:"<<endl;
cout<<"按成绩查询请按3:"<<endl;
int i;
char way(i);
cin>>i;
while(strcmp(way,"1")!=0&&strcmp(way,"2")!=0&&strcmp(way,"3")!=0&&strcmp(way,"4")!=0)
{
cout<<"***输入错误***请重新输入:";
cin>>way;
}
if(strcmp(way,"1")==0)
{
look1();
}
if(strcmp(way,"2")==0)
{
look2();
}
if(strcmp(way,"3")==0)
{
look3();
}
void look1()
{
int max;
ifstream fin1("max.dat");
if(!fin1)
{
cout<<"打开文件失败!";
exit(1);
}
fin1>>max;
ifstream fin3("student.dat");
if(!fin3)
{
cout<<"open error!"<<endl;
exit(1);
}
for(int i=0;i<max;i++)
{
fin3>>stu[i].number>>stu[i].name>>stu[i].sex>>stu[i].banji>>stu[i].grade;
}
cout<<"请输入学生学号:";
int num;
cin>>num;
cout<<"查询结果"<<endl;
int bianbie2=0;
for(int j=0;j<max;j++)
{
if(stu[j].number==num)
{
++bianbie2;
cout<<"学号:"<<stu[j].number<<"姓名:"<<stu[j].name<<"性别:"<<stu[j].sex<<"班级:"<<stu[j].banji<<"成绩:"<<stu[j].grade<<endl;
}
}
if(bianbie2==0)
{
cout<<"没有你查询的同学"<<endl;
}
fin3.close();
} 展开
1个回答
展开全部
应该是这个地方吧
int i;
char way(i);
cin>>i;
while(strcmp(way,"1")!=0&&strcmp(way,"2")!=0&&strcmp(way,"3")!=0&&strcmp(way,"4")!=0)
int i;
char way(i);
cin>>i;
while(strcmp(way,"1")!=0&&strcmp(way,"2")!=0&&strcmp(way,"3")!=0&&strcmp(way,"4")!=0)
追问
是啊,请问怎么改呢
追答
你的前面已经把它定义为int了,后面有参与char运算,这是不允许的,应该把他们统一使用。
或者都用int,或者都用char,看你的程序都用char就行了吧
不太清楚,char way(i);这句是干什么用的?
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询