没有少啊,这些错误是怎么回事啊?
#include <iostream>#include <string>
using namespace std;
int i=1;
struct Book{
char name;
int ID;
int price;
struct date;
}; Book b[20];
struct Date{
int year;
int month;
int day;
};
voivoid add()
{
cout<<"输入书的名字,ID,价格,出版日期。\n";
cin>> b[i].name>> b[i].ID>> b[i].price>> b[i].date.year>> b[i].date.month>> b[i].date.day;
}
void putdown()
{int k,j;char name[20];
cout<<"输入书的名字\n";
cin>>name;
for(j=1;j<i;j++)
{if(strcmp(name,b[j].name)==0)
break;}
cout<<"把 "<<b[j].name<<" 从书篮中拿出";
for(k=j+1;k<i;k++){b[k-1]=b[k];}
i--;
}
void search_the_highest()
{
int max=0; int j;
for(j=1;j<=i;j++){if (b[j].price>max) max=b[j].price;}
for(j=1;j<=i;j++)
{
if (b[j].price==max)
{cout<<"最贵的书是:\n"; cout<<"名字:"<<b[j].name <<"ID:"<<b[j].ID <<"价格:"<<b[j].price <<"出版日期:"<<
b[j].date.year<<'-'<<b[j].date.month<<'-'<<b[j].date.day;
}
}
}
int search_the_total_money()
{int total=0;int j;
for(j=1;j<=i;j++){total+=b[j].price;}
return total;
}
int main()
{
int select;
while (1)
{
cout<<"1.添加一本书.\n";
cout<<"2.放下一本书.\n";
cout<<"3.查询最贵的书.\n";
cout<<"4.查询当前书篮中书的总价.\n";
cout<<"5.退出\n";
cin>>select;
switch(select)
{
case 1:add();i++;break;
case 2:putdown();break;
case 3:search_the_highest();break;
case 4:search_the_total_money();break;
case 5:return 0;
}
}
}
错误
E:\程序源代码2\Cpp1.cpp(17) : error C2146: syntax error : missing ';' before identifier 'add'
E:\程序源代码2\Cpp1.cpp(17) : error C2501: 'voivoid' : missing storage-class or type specifiers
E:\程序源代码2\Cpp1.cpp(17) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
求大神解答