| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1294 人关注过本帖
标题:崩溃了,求解。银行管理系统中的销户与修改密码,谢谢,一输入密码和账号, ...
只看楼主 加入收藏
漠河120028
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2017-3-4
收藏
 问题点数:0 回复次数:3 
崩溃了,求解。银行管理系统中的销户与修改密码,谢谢,一输入密码和账号,就退出,其他函数的没有附上,希望能帮忙,万分感谢,
程序代码:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<conio.h>
#define N  1000
#define E  10
struct chuhu
{
    char idnum[9];                //账户
    char password[7];            //密码
    char name[11];              //姓名
    char idnumber[19];         //身份证
    double cunkuan;        //存款金额
   struct chuhu *next;
}hu[N];
struct chuhu *deleta(struct chuhu *head);
int  rrekey() ;               //修改密码
void enter();                  //登录函数
void menu();                    //输出主菜单2 
void display();                //显示账户余额
int A=0,key;              //A为开户数
double jin;
char ch='y';
char password[7];
int k;
int flag=0;
struct chuhu*Readfile(struct chuhu*head)
{
    struct chuhu *p=NULL,*pr=head;
    FILE *fp;

 
    if((fp=fopen("chuhu.txt","r"))==NULL)
    {
        printf("Failure to open yonghu,txt!\n");
        exit(0);
    }
     while(!feof(fp))
    {
        p=(struct chuhu *)malloc(sizeof(struct chuhu));
        fread(p,sizeof(struct chuhu),1,fp);
        if(head==NULL)
        {
            head=p;
            //pr=head;
        }
        else
        {
            while(pr->next!=NULL)
            {
                pr=pr->next;
            }
            pr->next=p;
            //pr=p;
        }
        //pr->next=NULL;
        p->next=NULL;
    }
    fclose(fp);
    return head;
}
struct chuhu *saveTorfile(struct chuhu *head)
{
    struct chuhu *p=head;
    FILE *fp;
    if((fp=fopen("chuhu.txt","w"))==NULL)
    {
        printf("Failure to open idcard.txt!\n");
        exit(0);
    }
    else
    {
        while(p->next!=NULL)
        {
            fwrite(p,sizeof(struct chuhu),1,fp);
            p=p->next;
        }
    }
    fclose(fp);
    return head;
}
void Displynode(struct chuhu *head)
{
    struct chuhu *p=head;
    while(p->next!=NULL)
    {
        printf("%10s%10s%20s%10s%15lf\n",p->idnum,p->name,p->idnumber,p->password,p->cunkuan);
        p=p->next;
    }
}
int main()//输出主菜单1
{
    FILE *fkey = fopen("key.txt","r");
    char c;
    int t=0;
    
    system("cls");
    printf("\n\n");
    printf("                        欢迎登陆银行管理系统\n");
    printf("                  请确保您周边的取款环境安全\n");
    printf("                   请勿相信周边粘贴的任何信息\n");
    printf("                  如有任何疑问请你致电本行24小时服务热线\n");
    printf("                     是否继续,继续请按Y,否按N\n");
    fflush(stdin);//清除输入缓冲区
    {
        c=getchar();
        getchar();
        if(c=='N')    
            exit(0);
        else  if(c=='y'||c=='Y')
        system("cls");
        menu();
        enter();
        return 0;    
    }
}
        
void menu()//输出主菜单2
{
    int a;
    printf("\n");
    printf("                 ----------------------------------------\n");
    printf("                ***!      请选择操作类型            !***\n");
    printf("                ***$         开户请按1              $***\n");
    printf("                ***&         登录请按2              &***\n");
    printf("                ***#         返回请按3              #***\n");
    printf("                ----------------------------------------\n");
    printf("                &&&&&^^^^ ");
    fflush(stdin);
    scanf("%d",&a);
    switch(a)
    {
        case 1:
          insert();
          break;
        case 2:
          enter();
          break;
        case 3:
            exit(0);
        default:
            printf("invalid operator !\n");
            exit(0);
    }
}
void  enter()
{
    int b;
    struct chuhu *head=NULL;
    do{
     printf("\n\n");
     printf("             ****           欢迎登录个人账户系统                 ****\n");
     printf("             !*!*            您可以选择以下操作                   *!*\n");
     printf("             ****            1.取款     2.存款                   ****\n");
     printf("             ****            3.转账     4. 销户                  ****\n");
     printf("             ****            5.挂失    6.查询余额                ****\n");
     printf("             ****            7.修改密码  8.查询交易记录          ****\n");
     printf("            ****            请选择您需要的服务                  ****\n");
     printf("              &&&&^^^^^");
     fflush(stdin);
    scanf("%d",&b);
    
    switch(b)
    {
        case 1:
          withdraw();
          break;
        case 2:
         saving();
          break;
        case 3:
            exit(0);
         case 4:
            system("cls");
            head=Readfile(head);
            head=deleta(head);
            head=saveTorfile(head);
            Displynode(head);
            break;
         case 5:
              flag=guashi();
              break;
          case 6:
            display();
            break;
        case 7:
        rrekey();                      
            break;
        default:
            printf("invalid operator !\n");
    }
    
    }while(1);
    
}

int rrekey() //修改密码
{
   FILE *rekey=fopen("key.txt", "r" );
   FILE *rkey=fopen("keynew.txt", "w" );
    int mima,mima1,mima2,t;
    system("cls");
    printf("请输入原密码\n:");
    scanf("%d",&mima);
    fscanf(rekey,"%d",&key); 
    if(mima==key) 
        t=1;
    system("cls");
    for(;t!=1;)
    {    
        printf("密码错误,请重新输入\n密码:");
        scanf("%d",&mima);
        if(mima==key)
            t=1;
        system("cls"); 
    }  
    printf("请输入新密码:\n");
    scanf("%d",&mima1); system("cls");
    printf("请再次输入新密码:\n");
    scanf("%d",&mima2);
    system("cls");
        if(mima1==mima2)
         {
            fprintf(rkey,"%d",mima1);
            printf("修改成功\n");
            system("pause");
         }
         else
        {
        printf("输入错误密码,终止修改密码操作");
        system("pause");
        }
        system("cls");
        fclose(rekey);
        fclose(rkey);
        system("del key.txt");
        rename("keynew.txt","key.txt");
        return 0;
}
struct chuhu *deleta(struct chuhu *head)
{
     FILE *fp;
     struct chuhu*p=head,*pr=head;
     int w3=0,c=0;
    int i,j;
    char idnum[9];
    char fnumb[9],keyword[7];
    printf("请输入你的账号:");
    scanf("%s",&fnumb);
    for(i=0;i<=99;i++)
    {
    if(strcmp(fnumb,hu[i].idnum)==0 )
        {
             do
            { 
                printf("\n\n\t\t*******请输入密码:<      >\b\b\b\b\b\b\b");
                scanf("%s",keyword);
              if(strcmp(hu[i].password,keyword)!=0)
        {
           printf("\n\n\t\t********密码不正确,请重新输入!**********\n");
           continue;
        }
        else
        {
            printf("\n\n\t\t**********密 码 正 确 !***********\n");
            w3=1;
        }
    }
    while(w3==0&&c<3);
   while(p->idnum!=p->idnum||strcmp(p->password,password)!=0&&p->next!=NULL)
   {
       pr=p;
       p=p->next;
   }
   if(p->idnum==idnum&&strcmp(p->password,password)==0)
   {
       if(p==head)
       {
            head=p->next;
       }
       else
       {
           pr->next=p->next;
       }
       free(p);
       printf("删除成功!\n");
   }
   else
   {
       printf("没有您要删除的信息!,请返回上一级\n");
   }
     return head;
      if((fp=fopen("chuhu.txt","w"))==NULL)
            {
                printf("打开文件失败!\n");
                exit(0);
            }
            fwrite(hu,sizeof(hu),j,fp);
            fclose(fp);
            if((fp=fopen("idcard.txt","r"))==NULL)
            {
                printf("打开文件失败!\n");
                exit(0);
            }
            j=2;
            for(i=0;!feof(fp);i++)
            {
                fread(&hu[i],sizeof(hu),j,fp);
            }
            fclose(fp);
            printf("%10d%10s%20s%10s%15lf%10d\n",
                hu[i].idnum,hu[i].name,hu[i].idnumber,hu[i].password,hu[i].cunkuan);
        }
        else
        {

        }
    }
     
}


[此贴子已经被作者于2017-3-20 21:03编辑过]

搜索更多相关主题的帖子: 修改密码 银行管理 输入密码 color 账号 
2017-03-20 21:00
漠河120028
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2017-3-4
收藏
得分:0 
回复 楼主 漠河120028
求修改
2017-03-20 21:01
漠河120028
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2017-3-4
收藏
得分:0 
回复 楼主 漠河120028
求修改
2017-03-20 21:01
姚萌萌
Rank: 2
来 自:湖北
等 级:论坛游民
帖 子:40
专家分:55
注 册:2016-12-25
收藏
得分:0 
回复 楼主 漠河120028
为什么要用system("pause")呢?如果你想让程序停一会的话可以用delay(时间)或者Sleep(时间),pause是停止程序
2017-03-20 23:28
快速回复:崩溃了,求解。银行管理系统中的销户与修改密码,谢谢,一输入密码和账 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.021794 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved