关于帐号密码的问题
突发奇想,写了一段码程序代码:
#include<stdio.h> #include<stdlib.h> #include<string.h> #include<conio.h> #define LEN sizeof(struct zhanghu) struct zhanghu { char zhanghu_zhanghao[20]; char zhanghu_mima[16]; struct zhanghu *next; }; int n; int zhuce(struct zhanghu *head,struct zhanghu *p1,struct zhanghu *p2) { int len,ch; while(p1->zhanghu_zhanghao!=0) { n=n+1; if(n==1)head=p1; else p2->next=p1; p2=p1; p1=(struct zhanghu *)malloc(LEN); printf("帐号:"); lable1: gets(p1->zhanghu_zhanghao); len=strlen(p1->zhanghu_zhanghao); if(len>20) { printf("过长\n"); printf("请重新输入帐号:"); goto lable1; } if(len<6) { printf("过短\n"); printf("请重新输入帐号:"); goto lable1; } printf("\n密码:"); lable2: while((p1->zhanghu_mima=getch())!='\n') printf("*"); len=strlen(p1->zhanghu_mima); if(len>16) { printf("过长\n"); printf("请重新输入密码:"); goto lable1; } if(len<6) { printf("过短\n"); printf("请重新输入密码:"); goto lable1; } } } /*void denglu(struct zhanghu head,struct zhanghu *p1,struct zhanghu *p2) { char zhanghaoa[],mimaa[]; printf("帐号:"); gets(zhanghaoa); printf("\n密码:"); gets(mimaa); }*/ struct zhanghu *creat(void) { struct zhanghu *p1,*p2; struct zhanghu *head; char a; head=NULL; n=0; p1=p2=(struct zhanghu *)malloc(LEN); zhuce(head,p1,p2); /*printf("是否注册帐号Y,或N,或登录L:"); scanf("%c",&a); if(a='Y'||'y') zhuce(head,p1,p2); if(a='N'||'n') denglu(head,p1,p2);*/ } /*还没写完,为什么会报错?我觉得已经对了吧! */
[ 本帖最后由 lyj23 于 2011-2-15 10:47 编辑 ]