void change()
{
[color=#FF0000]struct book *p,*head,*q=NULL; //missing ';' before 'type
system("cls"); //missing ';' before 'type/
int n=1,amount;//missing ';' before 'type
char isbn[20]={'\0'},name[20]={'\0'},author[20]={'\0'},print[20]={'\0'},name1[20]={'\0'},zone[15]={'\0'};//missing ';' before 'type/
float price;
p=head=read();
display();
printf("輸入要修改的圖書書名\n");
scanf("%s",name);
while(p)
{
if(strcmp(p->book1.name,name)==0)//查找要修改的書籍,找到后跳出回圈
{
q=p;
break;
}
else
p=p->next;
}
while(n!=0)
{
printf("請選擇您要修改的資訊,退出修改請按0\n");
printf("*------------------------------------------------------*\n");
printf("*1.修改ISBN序號 2.修改作者資訊 3.修改出版社資訊 *\n");
printf("*4.修改數量 5.修改單價 6.修改書名 *\n");
printf("*7.修改編號 *\n");
printf("*------------------------------------------------------*\n");
scanf("%d",&n);
switch(n)
{
case 1: printf("輸入新ISBN序號:"); scanf("%s",isbn); strcpy(q->book1.isbn,isbn);break;
case 2: printf("輸入新作者資訊:"); scanf("%s",author); strcpy(q->book1.author,author);break;
case 3: printf("輸入新出版社資訊;");scanf("%s",print); strcpy(q->book1.print,print);break;
case 4: printf("輸入新數量;"); scanf("%d",&amount); q->book1.amount=amount;break;
case 5: printf("輸入新單價;"); scanf("%f",&price); q->book1.price=price;break;
case 6: printf("輸入新書名:"); scanf("%s",name1); strcpy(q->book1.name,name1);break;
case 7: printf("輸入新編號:"); scanf("%s",zone); strcpy(q->book1.zone,zone);break;
/*default :printf("輸入錯誤,請重新輸入!\n");break;*/
}
}
write(head); //將修改后的資訊存入檔案
printf("修改成功!\n");
display();
}
//查找書籍
void find()
{
struct book *head=NULL,*p;
char name[20]={'\0'};
int flag=0;
char n=1;
system("cls");
head=read();//讓head指向傳入檔案資料的鏈表
p=head;
printf("輸入查找書籍相關資訊(ISBN/書名/作者)(注意不得超過20個字):\n");
scanf("%s",name); //: error C2065: 'name' : undeclared identifie
while(p)
{
if(strcmp(p->book1.name,name)==0)//查找要修改的書籍,找到后跳出回圈 /warning C4047: 'function' : 'const char *' differs in levels of indirection from 'int '//warning C4024: 'strcmp' : different types for formal and actual parameter 2
{
q=p;
break;
}
else
p=p->next;
}
while(n!=0) //c:: error C2065: 'n' : undeclared identifier
{
printf("請選擇您要修改的資訊,退出修改請按0\n");
printf("*------------------------------------------------------*\n");
printf("*1.修改ISBN序號 2.修改作者資訊 3.修改出版社資訊 *\n");
printf("*4.修改數量 5.修改單價 6.修改書名 *\n");
printf("*7.修改編號 *\n");
printf("*------------------------------------------------------*\n");
scanf("%d",&n);
switch(n)
{
case 1: printf("輸入新ISBN序號:"); scanf("%s",isbn); strcpy(q->book1.isbn,isbn);break; //error C2065: 'isbn' : undeclared identifier //warning C4047: 'function' : 'const char *' differs in levels of indirection from 'int '
//warning C4024: 'strcpy' : different types for formal and actual parameter 2
case 2: printf("輸入新作者資訊:"); scanf("%s",author); strcpy(q->book1.author,author);break; //error C2065: 'author' : undeclared identifier
//warning C4047: 'function' : 'const char *' differs in levels of indirection from 'int '
// warning C4024: 'strcpy' : different types for formal and actual parameter 2
case 3: printf("輸入新出版社資訊;");scanf("%s",print); strcpy(q->book1.print,print);break; //error C2065: 'print' : undeclared identifier
//warning C4047: 'function' : 'const char *' differs in levels of indirection from 'int '
//warning C4024: 'strcpy' : different types for formal and actual parameter 2
case 4: printf("輸入新數量;"); scanf("%d",&amount); q->book1.amount=amount;break; //'amount' : undeclared identifier
//warning C4047: 'function' : 'const char *' differs in levels of indirection from 'int '
//warning C4024: 'strcpy' : different types for formal and actual parameter 2
case 5: printf("輸入新單價;"); scanf("%f",&price); q->book1.price=price;break; //error C2065: 'price' : undeclared identifier
case 6: printf("輸入新書名:"); scanf("%s",name1); strcpy(q->book1.name,name1);break;//error C2065: 'name1' : undeclared identifier
// warning C4024: 'strcpy' : different types for formal and actual parameter 2
//warning C4024: 'strcpy' : different types for formal and actual parameter 2
case 7: printf("輸入新編號:"); scanf("%s",zone); strcpy(q->book1.zone,zone);break; //error C2065: 'zone' : undeclared identifier
// warning C4024: 'strcpy' : different types for formal and actual parameter 2
//warning C4024: 'strcpy' : different types for formal and actual parameter 2
/*default :printf("輸入錯誤,請重新輸入!\n");break;*/
}
}
write(head); //將修改后的資訊存入檔案
printf("修改成功!\n");
display();
}
uj5u.com熱心網友回復:
發一個干凈的完整代碼出來注意換行和對齊~
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/42736.html
標籤:C語言
