유형 구조체 struct variables, 과 함께 의사 결정문을 사용하는 데 문제가 있습니다. 변수를 어디에도 0으로 선언 할 수 없습니다. 여기 유형 def 구조체 변수가있는 조건문을 사용하는 데 문제가 있습니다.
는 구조체typedef struct{
int wallet;
int account;
}MONEY;
그것은 MONEY money;
으로 메인에 선언이다 내가이
(하지만 *의 m와 문제가 함수 메신저에 대한)
*m.wallet = *m.wallet - depositAmmount;
하거나
*m.wallet = 0;
표현식에 클래스 유형이 있어야한다는 구문 오류가 발생합니다. 나는 무엇을합니까? 함수 내부에는 내가 아무 소용이 아래
에 INT *m.wallet = 0;
심지어 DATE *m.wallet;
를 선언 시도하면 ->
연산자를 사용하는 구조체에 대한 포인터의 멤버에 액세스하려면 전체 기능
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#define clear system("clear")
#define pause system("pause")
void banking(MONEY *m){
int userChoice = 0;
int withdrawAmmount = 0;
int depositAmmount = 0;
do{
userChoice = 0;
withdrawAmmount = 0;
depositAmmount = 0;
displayBankMenu(*m);
scanf("%i", &userChoice);
clear;
switch (userChoice) {
case 1:
printf("How much would you like to Deposit?: $");
scanf("%i", &depositAmmount);
if(depositAmmount <= *m.wallet){
*m.wallet = *m.wallet - depositAmmount;
*m.account = *m.account + depositAmmount;
}else{
printf("You do not have sufficient funds for this transaction.");
pause;
}
break;
case 2:
printf("How much would you like to withdraw?: $");
scanf("%i", &withdrawAmmount);
if(withdrawAmmount <= *m.account){
*m.account = *m.account - withdrawAmmount;
*m.wallet = *m.wallet + withdrawAmmount;
} else{
printf("You do not have sufficient funds for this transaction.");
pause;
}
userChoice = 0;
break;
}
}while(userChoice != 3);
} //end banking
정말 고마워요! 나는 지금 이해한다. 그리고 나는 장래의 참조를 위해 두 번째 부분을 기억할 것이다! :) – user3027779
대단히 환영합니다. – jxh