dimanche 16 octobre 2016

Having trouble with calling to a function, and echoing to output and input file in C program bank account lab

I was assigned to create a program to ask the user if he wants to deposit or withdraw from his bank account. After they choose its suppose to display the overall balance of the bank account. I am having trouble figuring out how to call the function properly after they choose an option.

    #include <stdio.h>

FILE *fpin;
FILE *fpout;

char code;
double deposit;
double withdraw;
double balance;


void D(double balance, double deposit) {
    printf("and the amount is:");
    fscanf(fpout, "%f", &deposit);
    printf("The balance is: %f", balance);
    return 0;
    }

void C(double balance, double withdraw) {
    printf("and the amount is:");
    fscanf(fpin, "%d", &withdraw);
    printf("The balance is %f", balance);
    return 0;
}

int main(void) {

    balance = balance + deposit;
balance = balance - withdraw;
fpin = fopen("transactions.txt", "r");
fpout = fopen("processed.txt", "w");

printf("Welcome to Chris's Checking Account Tracer Program");
printf("\n------------------------------------------------------\n");
printf("The transaction is a: ");
fscanf(fpout, "%d", &code);
if (code == D) {
    D(balance, deposit);
}

else if (code == C) {
    C(balance, withdraw);
}
getchar();
return 0;

}

Aucun commentaire:

Enregistrer un commentaire