我已經差不多完成了這個銀行程序在你的幫助下(我之前曾問過關於同一個代碼的問題)。但我想鏈接銀行賬戶用戶的號碼和他的餘額C代碼與文本文件。我不知道這是否可能,因爲我是編程新手。我在這個網站上看到了其他相關的問題,因此我問了這個問題。謝謝!使用銀行程序的文本文件在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();
}
這是功課? – teukkam
看看這個:http://dirac.org/linux/programming/tutorials/files_in_C/ –
nope.homework是上面的代碼。這只是我的興趣。 –