i cant run my manager function part~

i just wanna run my manager function..
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<time.h>
#include<windows.h>

typedef struct {
int date, month, year, hr, min, sec;
}DATETIME;

typedef struct {
char accNo[6], PIN[6], name[31], gender, address[31], state[11], contact[12];
int balance;
DATETIME lastTxn;
}CUSTOMER;
typedef struct {
DATETIME TxnDT;
int ATMno;
char AccNo[10];
int TxnCode;
double amount,prevbal,newbal;
}TxnA;

typedef struct {
DATETIME TxnDT;
int ATMno;
char AccNo[10];
int TxnCode;
double amount;
char bankCode[15];
int cheqNo;
double prevbal,newbal;
}TxnB;

typedef struct {
DATETIME TxnDT;
int ATMno;
char AccNo[10];
int TxnCode;
double amount;
char RecAcc[10];
double RecPrevbal,RecNewbal,prevbal,newbal;
}TxnC;
typedef struct
{
char bank[15];
}BANKCODE;


int atm, choice, txnCode, customerCode;
CUSTOMER temp,rcp, customer[10];
FILE *fptr1, *fptr2, *fptr3;
SYSTEMTIME t;
TxnA tempdep,tempwthdr;
TxnB tempcheq;
TxnC temptransfer;
int temp,tempRec;
void transaction(int TxnCode);
int withdrawal(int balance, int withdraw);
char temp_pw[10],password[]="mama";
int get=0,tryagain=1;
int BANKCODE;
void PrtTxnLog();
void Update();
void WithdrawalLog();
void TransferLog();
void CashDepLog();
void ChequeDepLog();

void transaction(int TxnCode) {
int withdraw, transfer, deposit;

switch(TxnCode) {
//cashdep
case 1: {
//chequedep
}
case 2:{

}


//Withdrawal
case 3: {
printf("WITHDRAWAL\n\n");
printf("Your Balance is RM%d\n", temp.balance);
printf("Please key in the amount you want to withdraw:\nRM");
scanf("%d", &withdraw);

//Update balance
customer[customerCode].balance = withdrawal(temp.balance, withdraw);

//Update last transaction date & time
GetLocalTime(&t);
customer[customerCode].lastTxn.date = t.wDay;
customer[customerCode].lastTxn.month = t.wMonth;
customer[customerCode].lastTxn.year = t.wYear;
customer[customerCode].lastTxn.hr = t.wHour;
customer[customerCode].lastTxn.min = t.wMinute;
customer[customerCode].lastTxn.sec = t.wSecond;

printf("Withdrawal Successful. Your balance is now RM%d\n", customer[customerCode].balance);

//Rewrite customer's details into a temporary text file
for(int i = 0; i < 10; i++) {
fprintf(fptr2, "%s|%s|%s|%c|%s|%s|%s|%d|%d %d %d %d %d %d\n",
customer[i].accNo, customer[i].PIN, customer[i].name, customer[i].gender,
customer[i].address, customer[i].state, customer[i].contact,
customer[i].balance, customer[i].lastTxn.date, customer[i].lastTxn.month, customer[i].lastTxn.year,
customer[i].lastTxn.hr, customer[i].lastTxn.min, customer[i].lastTxn.sec);
}

break;
}
//Funds Transfer
case 4: {

printf("FUNDS TRANSFER\n\n");
printf("Your Balance is RM%d\n", temp.balance);
printf("Enter the Account Number of the Recipient: ");
scanf("%s", &rcp.accNo);
fflush(stdin);

for(int i = 0; i < 10; i++)
{
fscanf(fptr1, "\n%[^|]|%[^|]|%[^|]|%c|%[^|]|%[^|]|%[^|]|%d|%d%d%d%d%d%d\n",
&customer[i].accNo, &customer[i].PIN, &customer[i].name, &customer[i].gender,
&customer[i].address, &customer[i].state, &customer[i].contact,
&customer[i].balance, &customer[i].lastTxn.date, &customer[i].lastTxn.month, &customer[i].lastTxn.year,
&customer[i].lastTxn.hr, &customer[i].lastTxn.min, &customer[i].lastTxn.sec);
//Check if the results match
if(strcmp(rcp.accNo, customer[i].accNo) == 0)
strcpy(rcp.name, customer[i].name);
}

printf("Receiver Name:%s\n",rcp.name);

//Read and Prompt transfer amount(update is pending)
printf("Enter the amount to Transfer(0 to cancel):\nRM");
scanf("%d", &transfer);

temp.balance = temp.balance - transfer;

printf("Funds Transfer Successful. Your balance is now RM%d\n", temp.balance);
}

break;
}
}

//Withdrawal Calculator
int withdrawal(int balance, int withdraw){
int final;
final = balance - withdraw;
return final;
}
//transfers Calculator
int transfers(int balance, int transfer){
int final;
final = balance - transfer;
return final;
}

int main() {
system("color 8a");

SYSTEMTIME t;
int choice, txnCode;


//TARBANK Logo
//Display Today's Date and Time
GetLocalTime(&t);
printf("\t\tWelcome To TARBANK! Today is %d/%d/%d and \n\
it's %d:%d:%d now.\n\n", t.wDay, t.wMonth, t.wYear, t.wHour, t.wMinute, t.wSecond);

printf("\t\tCustomer:Press 1\n");
printf("\t\tManager:Press 2\n\n");
printf("\t\tYour choice: ");
scanf("%d", &choice);
if(choice == 1) {
fptr1 = fopen("Customer.txt", "r");
fptr2 = fopen("Customer_temp.txt", "w");

//Check if customer.txt can be opened or not
if(fptr1 == NULL || fptr2 == NULL) {
printf("ERROR in opening file!Try again.....");
exit(-1);
}
else if(choice == 2){
do{printf("\n\n"
"\t PLEASE INSERT THE PASSWORD TO ENTER THE MANAGER MENU\n"
"\t\t >>>>> ");
fflush(stdin);
scanf("%[^\n]",&temp_pw);
if(strcmp(temp_pw,password)==0) {
get=1;
tryagain=0;
do {
printf("\n\n"
"\t\t\t *--------------*\n"
"\t\t\t | MANAGER MENU |\n"
"\t\t\t *--------------*\n"
"\t\t Which would you like to process ? __\n"
"\t\t\t[1] Print Transaction Log\n"
"\t\t\t[2] Perform Updates\n"
"\t\t Your choice >> ");
fflush(stdin);
scanf("%d",&choice);
switch(choice) {
case 1:
PrtTxnLog();
break;
case 2:
Update();
break;
default:
printf("\n"
"\t\t\t +-----------------+\n"
"\t\t\t | Invalid choice! |\n"
"\t\t\t +-----------------+\n");
}
}while(choice!=1 && choice!=2);
}
if(get==0) {
printf("\n"
"\t\t\t+------------------------+\n"
"\t\t\t| ERROR! WRONG PASSWORD! |\n"
"\t\t\t+------------------------+\n");
}
}while(tryagain!=0);
}


//Randomly generate ATM No.(6-10)
srand(time(NULL));
atm = (rand() % 5) + 6;
//Display ATM No.
printf("ATM No: %d\n", atm);

//Prompt and read user's A/C No.
printf("\t\tPlease enter your A/C No:\t\t_____\b\b\b\b\b");
scanf("%s", &temp.accNo);
fflush(stdin);

//Prompt and read user's PIN No.
printf("\t\tPlease enter your PIN No:\t\t_____\b\b\b\b\b");
scanf("%s",temp.PIN);
fflush(stdin);

//Read customer.txt
while(!feof(fptr1)) {
for(int i = 0; i < 10; i++) {
fscanf(fptr1, "\n%[^|]|%[^|]|%[^|]|%c|%[^|]|%[^|]|%[^|]|%d|%d%d%d%d%d%d",
&customer[i].accNo, &customer[i].PIN, &customer[i].name, &customer[i].gender,
&customer[i].address, &customer[i].state, &customer[i].contact,
&customer[i].balance, &customer[i].lastTxn.date, &customer[i].lastTxn.month, &customer[i].lastTxn.year,
&customer[i].lastTxn.hr, &customer[i].lastTxn.min, &customer[i].lastTxn.sec);

//Check if the results match(update is pending)
if(strcmp(temp.accNo, customer[i].accNo) == 0 && strcmp(temp.PIN, customer[i].PIN) == 0) {
customerCode = i;

strcpy(temp.name, customer[i].name);
temp.balance = customer[i].balance;

temp.gender = customer[i].gender;
strcpy(temp.address, customer[i].address);
strcpy(temp.state, customer[i].state);
strcpy(temp.contact, customer[i].contact);
temp.lastTxn.year = customer[i].lastTxn.year;
temp.lastTxn.month = customer[i].lastTxn.month;
temp.lastTxn.date = customer[i].lastTxn.date;
temp.lastTxn.hr = customer[i].lastTxn.hr;
temp.lastTxn.min = customer[i].lastTxn.min;
temp.lastTxn.sec = customer[i].lastTxn.sec;
}
}
}

printf("\n");
printf("Name: %s\n\n", temp.name);
printf("Balance: RM%d\n\n", temp.balance);

printf("Last Transaction Date: %d/%d/%d %d:%d:%d\n\n", temp.lastTxn.date, temp.lastTxn.month, temp.lastTxn.year,
temp.lastTxn.hr, temp.lastTxn.min, temp.lastTxn.sec);

printf("\t\t[1] Withdrawal\n");
printf("\t\t[2] Funds Transfer\n\n");
printf("\t\t[3] Cash Deposit\n");
printf("\t\t[4] Cheque Deposit\n\n");

printf("\t\tYour choice: ");
scanf("%d", &choice);



//withdrawal
if(choice == 1) {
txnCode = 3;
transaction(txnCode);
}

//Transferr
else if(choice == 2) {
txnCode = 4;
transaction(txnCode);
}
//Cash Deposit(txnCode = 1)
if(choice == 3){
txnCode = 1;
transaction(txnCode);
}

//Cheque Deposit(txnCode = 2)
else if(choice == 4){
txnCode = 2;
transaction(txnCode);
}

.....still have a lot code. just help me access into manager part
Topic archived. No new replies allowed.