标题:我是一个菜鸟,正在写一个银行管理系统,写了这么多总是有错误,运行不了, ...
只看楼主
GBH1
Rank: 7Rank: 7Rank: 7
等 级:黑侠
威 望:5
帖 子:112
专家分:510
注 册:2017-6-13
得分:5 
使用scanf()函数前请先刷新缓冲区fflush(stdin), gets()函数使用时传递的是接收数据缓冲区指针。像你这个
int winlogon();//从这个开始开始,每个函数后面的分号是几个意思?
{
int i=0;
     printf("\n请输入您的卡号:");
     gets("card C1[0]");
     printf("\n请输入您的密码:");
while(++i <= 3)
{
     gets("password c1[0]");
...
gets()函数能起作用吗?
因该是这样gets(C1[0].card);
这表示给第一个用户的银行卡卡号赋值。
少年,看来你的基础有点弱啊,多看书吧。里面的逻辑就不提了
2017-07-06 11:20
乎uifhu
Rank: 1
等 级:新手上路
帖 子:22
专家分:0
注 册:2017-6-5
得分:0 
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int Winlogon();
int Manage();
void drawmoney();
void deposit();
void transfer();
void balance();
void open();
void closing();
void modify();
void information();
struct CCard
{
 char card[20];
 char password[7];
 int flag;
 float account;
};
 struct CCard C1[5];
 int Winlogon()
{

int i=0;
int n;
char input[10]={0};
     printf("\n请输入您的卡号:");
     scanf("%c",&C1[0].card);
     getchar();
     gets(input);
if(strcmp(C1[0].card,C1[0].card)==0)
{   
     printf("\n请输入您的密码:");
     scanf("%C",&C1[0].password);
     getchar();
while(++i <= 3)
{
     gets(input);
if(strcmp(C1[0].password,C1[0].password)==0)
{
    {
     printf("\n登陆成功,请输入相应编号进行以下操作:");
     printf("\n------------------------------------------------1.存款---------------------------------------------------------------");
     printf("\n------------------------------------------------2.取款---------------------------------------------------------------");
     printf("\n------------------------------------------------3.转账---------------------------------------------------------------");
     printf("\n------------------------------------------------4.余额查询-----------------------------------------------------------");
     printf("\n------------------------------------------------5.退出程序-----------------------------------------------------------");
     scanf("%d",&n);
    }
 switch(n)
{
case 1:drawmoney();break;
case 2:deposit();break;
case 3:transfer();break;
case 4:balance();break;
case 5:exit(0);
default:printf("\n输入错误,请重新输入!");break;
}
}
 
  else
  {
      printf("\n密码错误,请重新输入!");
     break;
     }
  if(i<3)
  {
      printf("\n请重新输入密码,你还有%d次机会",3-i);
  }
  else
  {
      printf("\n密码错误已超过三次,你的账户已被冻结!");
  }
}
}
else
{
    printf("\n您输入的卡号有误,请重新输入:");
}
return 1;
}

int Manage()
{
int n;
char m[10]="123";
char input[10]={0};

        printf("\n请输入管理员密码:");
       scanf("%c",&m[10]);
       gets(input);
if(strcmp(m,input)==0)
{
    {
       printf("\n------------------------------------------------1.添加银行卡---------------------------------------------------------------");
       printf("\n------------------------------------------------2.删除银行卡---------------------------------------------------------------");
       printf("\n------------------------------------------------3.改密---------------------------------------------------------------------");
       printf("\n------------------------------------------------4.信息查询-----------------------------------------------------------------");
       printf("\n------------------------------------------------5.退出程序---------------------------------------------------------\n");
       printf("\n登陆成功,请输入相应编号进行以下操作:");
       scanf("%d",&n);
    }

 switch(n)
{
 case 1:open();break;
 case 2:closing();break;
 case 3:modify();break;
 case 4:information();break;
 case 5:exit(0);
 default:printf("\n输入错误,请重新输入!");
}
}
else
     {
        printf("\n密码错误,请重新输入");
}
return 1;
}

void drawmoney()
{   
struct CCard C1={"000000000","000000",1,000};
int Num;
        printf("\n请输入存款金额:");
        scanf("%d",&Num);
        C1.account=C1.account+Num;
        getchar();
        printf("\n请把你的钱放到指定位置----");
}

void deposit()
{
struct CCard C1={"000000000","000000",1,000};;
char x;
        printf("\n请输入取款金额:");
        scanf("%f",&x);
if(C1.account>=x)
{
        C1.account=C1.account-x;
        printf("\n请取走您的钱----");
}
else
        printf("\n对不起,您的余额不足----");
}
void transfer()
{
struct CCard C1[5];
char y;
        printf("\n请输入需要转账的银行卡号:");
        scanf("%c",&C1[5].card);
        printf("\n请输入转账金额:");
        scanf("%f",&y);
if(C1[5].account>y)
{
        C1[0].account=C1[0].account-y;
        C1[1].account=C1[1].account+y;
        printf("\n恭喜您转账成功----");
}
else
{
        printf("\n对不起,您的余额不足----");
}
}
void balance()
{
        printf("\n您的银行卡余额剩余10000元----");
}
void open()
{
        printf("\n请依次输入卡号,密码,余额");
        scanf("%c%d%f",C1[5].card,C1[5].password,&C1[5].account);
        printf("\n添加银行卡成功!!!");
}
void closing()
{
        printf("\n请依次输入卡号,密码,余额");
        scanf("%c%d%f",C1[5].card,C1[5].password,&C1[5].account);
        printf("\n删除银行卡成功!!!");
}
void modify()
{
struct CCard C1[5];
char newpassword;

        printf("\n请输入您需要改密的银行卡卡号:");
        scanf("%c",&C1[5].card);
        printf("\n请输入您的旧密码:");
        scanf("%c",&C1[5].password);
if(strcmp("card C1[5]","password C1[5]")==0)
{
      printf("\n请输入您的新密码:");
        scanf("%c",&newpassword);
        printf("\n请再次输入");
        scanf("%c",&newpassword);
        printf("\n密码修改成功,请牢记!!!");
}
else
    printf("\n密码错误,请重新输入!!");

}
void information()
{
        printf("\n系统故障,请稍后再来!!!");
}
int main()
{
int n;
        printf("\n\n-----------------------------------------------欢迎进入银行管理系统!---------------------------------------------------");
        printf("\n\n-----------------------------------------------管理员密码:123----------------------------------------------------------");
 

        
        printf("\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
        printf("\n-----------------------------------------------1.银行卡管理--------------------------------------------------------------");
        printf("\n-----------------------------------------------2.银行卡登录--------------------------------------------------------------");
        printf("\n请输入相应编号进行以下操作:");
        scanf("%d",&n);
 
 switch(n)
{
 case 1:Manage();break;
 case 2:Winlogon();break;
 case 3:exit(0);
 default:printf("\n输入错误,请重新输入!");
}
 return 0;
}
2017-07-06 21:16
乎uifhu
Rank: 1
等 级:新手上路
帖 子:22
专家分:0
注 册:2017-6-5
得分:0 
调试了很多遍,终于可以运行了。。现在的问题是怎样让,在void open()函数运行过可以返回上一个函数。。。求助大神
2017-07-06 21:24



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-479167-1-1.html




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

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