如何解决 error C3861
数据结构,程序提示找不到标识符。程序代码:
#include <stdio.h> #include"stdlib.h" #include"string.h" typedef struct flower {char name[10]; char addr[10]; char color[10]; float price; int amount; char time[10]; char dtime[10]; struct flower *link;}lnode,*lnodelist; void creat(lnodelist &head) {int n=5;lnodelist p; head=(lnode*)malloc(sizeof(lnode)); head->link=NULL; p=head->link; while(!n) { p=(lnode*)malloc(sizeof(lnode)); printf("pleease input name,address,color,price,amount,time and expiration"); scanf("%s%s%s%f%d%s%s",&(p->name),&(p->addr),&(p->color),&(p->price),&(p->amount),&(p->time),&(p->dtime)); p->link=head->link;head->link=p; --n; } }//建立链表 lnodelist print(lnodelist head) { lnodelist p; if(head==NULL)printf("error!"); p=head; while(!p) { printf("%s%s%s%f%d%s%s\n",p->name,p->addr,p->color,p->price,p->amount,p->time,p->dtime); p=p->link; } return(head); }//输出链表 lnodelist cx(lnodelist head) { int n; printf("there are 7 choices./n1 stands for name;2 stands for addr;/n3 stands for color;4 stands for price;/n"); printf("5 stands for amount.6 stands for time;/n7 stands for dtime.please input one number./n"); scanf("%d",&n); switch(n) {case'1':cxname(head);break; case'2':cxaddr(head);break; case'3':cxcolor(head);break; case'4':cxprice(head);break; case'5':cxamount(head);break; case'6':cxtime(head);break; case'7':cxdtime(head);break; default: printf("error"); } return(head); } lnodelist sc(lnodelist head) { int n; printf("there are 7 choices./n1 stands for name;2 stands for addr;/n3 stands for color;4 stands for price;/n"); printf("5 stands for amount.6 stands for time;/n7 stands for dtime.please input one number./n"); scanf("%d",&n); switch(n) {case'1':scname(head);break; case'2':scaddr(head);break; case'3':sccolor(head);break; case'4':scprice(head);break; case'5':scamount(head);break; case'6':sctime(head);break; case'7':scdtime(head);break; default: printf("error"); } return(head); } lnodelist cxname(lnodelist head) { char n[10];lnodelist p; if(head==NULL)printf("error"); p=head; printf("input the flower's name/n"); gets(n); while(!p) { if(strcmp(p->name,n)==0)printf("%s%s%s%f%d%s%s\n",p->name,p->addr,p->color,p->price,p->amount,p->time,p->dtime); p=p->link; } return(head); } lnodelist cxaddr(lnodelist head) { char n[10];lnodelist p; if(head==NULL)printf("error"); p=head; printf("input the flower's address/n"); gets(n); while(!p) { if(strcmp(p->addr,n)==0)printf("%s%s%s%f%d%s%s\n",p->name,p->addr,p->color,p->price,p->amount,p->time,p->dtime); p=p->link; } return(head); } lnodelist cxcolor(lnodelist head) { char n[10];lnodelist p; if(head==NULL)printf("error"); p=head; printf("input the flower's color/n"); gets(n); while(!p) { if(strcmp(p->color,n)==0)printf("%s%s%s%f%d%s%s\n",p->name,p->addr,p->color,p->price,p->amount,p->time,p->dtime); p=p->link; } return(head); } lnodelist cxtime(lnodelist head) { char n[10];lnodelist p; if(head==NULL)printf("error"); p=head; printf("input the flower's time/n"); gets(n); while(!p) { if(strcmp(p->time,n)==0)printf("%s%s%s%f%d%s%s\n",p->name,p->addr,p->color,p->price,p->amount,p->time,p->dtime); p=p->link; } return(head); } lnodelist cxdtime(lnodelist head) { char n[10];lnodelist p; if(head==NULL)printf("error"); p=head; printf("input the flower's dtime/n"); gets(n); while(!p) { if(strcmp(p->dtime,n)==0)printf("%s%s%s%f%d%s%s\n",p->name,p->addr,p->color,p->price,p->amount,p->time,p->dtime); p=p->link; } return(head); } lnodelist cxprice(lnodelist head) { float n;lnodelist p; if(head==NULL)printf("error"); p=head; printf("input the flower's price"); scanf("%f",&n); while(!p) { if(n==p->price)printf("%s%s%s%f%d%s%s\n",p->name,p->addr,p->color,p->price,p->amount,p->time,p->dtime); p=p->link; } return(head); } lnodelist cxamount(lnodelist head) { int n;lnodelist p; if(head==NULL)printf("error"); p=head; printf("input the flower's amount"); scanf("%d",&n); while(!p) { if(n==p->amount)printf("%s%s%s%f%d%s%s\n",p->name,p->addr,p->color,p->price,p->amount,p->time,p->dtime); p=p->link; } return(head); } lnodelist scname(lnodelist head) { char n[10];lnodelist p,q; if(head==NULL)printf("error"); p=head; printf("input the flower's name/n"); gets(n); while(!p) { if(strcmp(p->name,n)==0)q=p->link;p->link=p->link->link;free(q); } return(head); } lnodelist scaddr(lnodelist head) { char n[10];lnodelist p,q; if(head==NULL)printf("error"); p=head; printf("input the flower's address/n"); gets(n); while(!p) { if(strcmp(p->addr,n)==0)q=p->link;p->link=p->link->link;free(q); } return(head); } lnodelist sccolor(lnodelist head) { char n[10];lnodelist p,q; if(head==NULL)printf("error"); p=head; printf("input the flower's color/n"); gets(n); while(!p) { if(strcmp(p->color,n)==0)q=p->link;p->link=p->link->link;free(q); } return(head); } lnodelist sctime(lnodelist head) { char n[10];lnodelist p,q; if(head==NULL)printf("error"); p=head; printf("input the flower's time/n"); gets(n); while(!p) { if(strcmp(p->time,n)==0)q=p->link;p->link=p->link->link;free(q); } return(head); } lnodelist scdtime(lnodelist head) { char n[10];lnodelist p,q; if(head==NULL)printf("error"); p=head; printf("input the flower's dtime/n"); gets(n); while(!p) { if(strcmp(p->dtime,n)==0)q=p->link;p->link=p->link->link;free(q); } return(head); } lnodelist scprice(lnodelist head) { float n;lnodelist p,q; if(head==NULL)printf("error"); p=head; printf("input the flower's price"); scanf("%f",&n); while(!p) { if(n==p->price)q=p->link;p->link=p->link->link;free(q); } return(head); } lnodelist scamount(lnodelist head) { int n;lnodelist p,q; if(head==NULL)printf("error"); p=head; printf("input the flower's amount"); scanf("%d",&n); while(!p) { if(n==p->amount)q=p->link;p->link=p->link->link;free(q); } return(head); } void main() {char f;int n=1; lnodelist head;head=NULL; printf("welcome to flower store information system\n"); printf("there are 4 functions:\n"); printf("zhuijia is A\nxiugai is B\nshanchu is C\nchaxun is D\n"); printf("please select a function:"); scanf("%c",&f); switch(f) {case 'A': if(n==1) {creat(head); break;} /*else {zj();break;}/*追加功能函数*/ /*case 'B':xg();break; /*修改功能函数*/ case 'C':sc(head);break; /*删除功能函数*/ case 'D':cx(head);break; /*查询功能函数*/ default:printf("there is an error!");/*输入命令错误*/ } }