Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在C语言中为银行程序使用文本文件_C_Visual Studio 2012 - Fatal编程技术网

在C语言中为银行程序使用文本文件

在C语言中为银行程序使用文本文件,c,visual-studio-2012,C,Visual Studio 2012,在你的帮助下,我几乎完成了这个银行程序(我之前问过一个关于同一代码的问题)。但是我想用一个文本文件链接这个C代码中的银行帐户用户的号码和他的余额。我不知道这是否可能,因为我对编程还不熟悉。我在这个网站上看到了其余的相关问题,因此我问了这个问题。谢谢大家! #include<stdio.h> #include<conio.h> int main(void) { int deposit,withdraw,kbalance; int option; int decash,wic

在你的帮助下,我几乎完成了这个银行程序(我之前问过一个关于同一代码的问题)。但是我想用一个文本文件链接这个C代码中的银行帐户用户的号码和他的余额。我不知道这是否可能,因为我对编程还不熟悉。我在这个网站上看到了其余的相关问题,因此我问了这个问题。谢谢大家!

#include<stdio.h>
#include<conio.h>
int main(void)
{
int deposit,withdraw,kbalance;
int option;
int decash,wicash;
int balance;
int wibal;

printf("Wel0ome to skybank\n");
printf("Enter your current Balance\n");
scanf_s("%d", &balance);
printf("Press 1 to deposit cash\n");
printf("Press 2 to Withdraw Cash\n");
printf("Press 3 to Know Your Balance\n");
printf("Press 4 to Quit\n");
while((option=getchar())!=4){
scanf_s("%d", &option);
switch(option)
   {
    case 1:
        printf("Enter the amount you want to deposit\n");
        scanf_s("%d", &decash);
        printf("Thank You\n");
        printf("%d have been deposited in your account\n", decash);
        balance=balance+decash;
        printf("Your balance is Rs.%d\n",balance);
        break;
    case 2:
        printf("Enter the amount you want to withdraw\n");
        scanf_s("%d", &wicash);
        wibal=balance-wicash;
        if(wicash<balance){
            printf("Thank You\n");
            printf("%d have been withdrawed from your account\n", wicash);
            printf("Your balance is Rs.%d\n", wibal);}
        else{
            printf("Sorry. You have insufficient balance to conduct         this transaction!\n");}
        balance=balance-wicash;
        break;
    case 3:
        printf("Your balance is Rs.%d\n", balance);
        break;
    case 4:
        exit();
        break;
    default:
        printf("Invalid Input\n");
        break;
    }
}
_getch();
}
#包括
#包括
内部主(空)
{
int存款、取款、余额;
int选项;
int decash,wicash;
国际收支平衡;
int wibal;
printf(“欢迎光临天空银行”\n);
printf(“输入您当前的余额\n”);
扫描单位(“%d”和余额);
printf(“按1存入现金”);
printf(“按2提取现金”);
printf(“按3键了解您的余额\n”);
printf(“按4退出\n”);
而((option=getchar())!=4){
扫描单位(“%d”和选项);
开关(选件)
{
案例1:
printf(“输入您要存入的金额\n”);
scanf_s(“%d”和decash);
printf(“谢谢你”);
printf(“%d已存入您的帐户\n”,decash);
平衡=平衡+脱灰;
printf(“您的余额为卢比%d\n”,余额);
打破
案例2:
printf(“输入要提取的金额\n”);
scanf_s(“%d”和wicash);
wibal=现金余额;
如果(wicash有一个结构

struct BankAccount
{
    int AccountNo;
    int Balance
} Accounts[NUM_OF_ACCOUNTS]

使用结构格式读/写文件当然可以

只是让自己熟悉如何用C语言处理文件。这里有一个很好的教程

看看这个:不,作业是上面的代码。这正是我的兴趣所在。