我有一个关于我正在编写的代码的快速问题。参考void RunBankMenu(int *choice)
and void TransactionDecision(...)
,我将如何使用从中获取的值RunBankMenu(Choice)
来设置 if/else 或 switch 语句TransactionDecision
?例如,如果用户选择 1,则 TransactionDecision 函数将使用我设置开关的批次代码。我如何将指针传递给另一个函数以便我可以读取值?
谢谢!
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#define MAXCREDIT -4500
void RunBankMenu(int *choice);
void Greeting();
void AccountBalance(double account, char letter);
void TransactionDecision(int num, double *cPtr, double *sPtr, double *xPtr);
void DepositMoney(double *accountPtr);
void WithdrawMoney(double *accountPtr, char letter);
int main()
{
double checkings = 430.00;
double savings = 812.00;
double credit = -2254.00;
int NumberChoice = 0;
Greeting();
AccountBalance(checkings, savings, credit);
RunBankMenu(&NumberChoice);
printf("%d", NumberChoice);
}
void Greeting()
{
printf("Welcome to the Bank of COP 2220\n\nIt is a pleasure to manage"
" your checking, savings, and credit accounts\n");
}
void AccountBalance(double account, char letter)
{
double checkings = 430.00;
double savings = 812.00;
double credit = -2254.00;
printf("-- You currently have $%.2f in your checking account\n",checkings);
printf("-- You currently have $%.2f in your savings account\n",savings);
printf("-- You currently have $%.2f credit balance\n", credit);
}
void RunBankMenu(int *choice)
{
do{
printf("-----------------------------\n");
printf("(1) to DEPOSIT to CHECKING\n");
printf("(2) to WITHDRAW from CHECKING\n");
printf("(3) to DEPOSIT to SAVINGS\n");
printf("(4) to WITHDRAW from SAVINGS\n");
printf("(5) to DEPOSIT to CREDIT\n");
printf("(6) to TAKE an ADVANCE from CREDIT\n");
printf("(7) to TRANSFER MONEY BETWEEN ACCOUNTS\n");
printf("(8) for all ACCOUNT BALANCES\n");
printf("\n(9) QUIT\n\n");
printf("Select an option: ");
scanf("%d", &*choice);
} while (*choice <= 8);
}
void TransactionDecision(int num, double *cPtr, double *sPtr, double *xPtr)
{
int num1;
}
void DepositMoney(double *accountPtr)
{
}
void WithdrawMoney(double *accountPtr, char letter)
{
}