I receive to build areas when I want to start my debugging. But the errors do not show up when i just compile.
They are:
error LNK2001: unresolved external symbol "void __cdecl withdraw(char,double &,double &,class std::basic_ifstream<char,struct std::char_traits<char> > &,struct node * &)" (?withdraw@@$$FYAXDAAN0AAV?$basic_ifstream@DU?$char_traits@D@std@@@std@@AAPAUnode@@@Z)
and
fatal error LNK1120: 1 unresolved externals.
Does anyone know what they mean?
By the way, I am using Microsoft Visual C++ as my compiler.
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <iomanip>
#include <cstring>
using namespace std;
struct node
{
int acctno; //customer account number
char pwd[4]; // customer password
double ckbal; // check balance
double svbal; // savings balance
node *next;
};
void loadfile(node *&); //load link list
void get_info(node *); // find account and password
char menu(); // display menu and get choice
char accounttype(); // display menu for what type of account to access
node * search_acctno(node *, int); // search for account
void balance(char &type, double ckbal, double svbal, ifstream &, node *&); //displays balance
void deposit(char type, double &ckbal, double &svbal, ifstream &fin, node *&); //deposit funds
void withdraw(char type, double &ckbal, double &svbal, ifstream &fin, node *&); //withdraw funds
void transfer(char type, double &ckbal, double &svbal, ifstream &fin, node *&); //transfer funds
int main()
{
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
node *beg; // pointer to 1st node in list
node *curr;
char choice, type; // menu choice
double ckbal, svbal;
ifstream fin;
loadfile(beg);
get_info(beg);
do
{
choice = menu();
switch(choice)
{
case 'I':
system ("cls"); //clear screen
accounttype();
balance(type, ckbal, svbal, fin, curr);
break;
case 'D':
system ("cls"); //clear screen
accounttype();
deposit(type, ckbal, svbal, fin, curr);
break;
case 'W':
system ("cls");
accounttype();
withdraw(type, ckbal, svbal, fin, curr);
break;
case 'T':
system ("cls");
accounttype();
transfer(type, ckbal, svbal, fin, curr);
break;
case 'X':
cout << "Thank you for using the First Stealing and Loan ATM Program.\n";
cout << "Come back soon." << endl;
break;
}
}while (choice != 'X');
return 0;
}
void loadfile(node *&beg)
{
node *end, *curr;
ifstream fin ("a:\\cust.doc", ios::in);
beg = new node; //dynamically allocate beginning node
if(!fin.is_open())
{
cerr << "Error: Could not open file.\n"; // file not opened
exit(1);
}
fin >> beg->acctno;
fin >> beg->pwd;
fin >> beg->ckbal;
fin >> beg->svbal;
beg->next = NULL;
end = beg;
while(!fin.eof())
{
curr = new node;
fin >> curr->acctno;
fin >> curr->pwd;
fin >> curr->ckbal;
fin >> curr->svbal;
curr->next = NULL;
}
return;
}
void get_info(node *beg)
{
int acctno;
char pwd[4];
cout << "Please enter account number: "; // get account number
cin >> acctno;
cout << endl;
if(acctno != NULL)
{
search_acctno(beg, acctno); //search for account
cout << "Please enter password: "; // get password
if(pwd != NULL)
{
cin >> pwd;
cout << endl;
}
else
{
cout << "Not found" << endl;
}
}
else
{
cout << "Not found" << endl;
}
return;
}
char menu()
{
char choice;
system ("cls"); // clear screen
cout << endl
<< "Enter I for Balance inquiry.\n"
<< "Enter D for Deposit funds.\n"
<< "Enter W for Withdraw funds.\n"
<< "Enter T for Transfer funds.\n"
<< "Enter X to Exit.\n"
<< "Enter choice and press Enter: ";
cin >> choice;
return choice;
}
char accounttype()
{
char type;
system ("cls"); // clear screen
cout << endl
<< "Enter C for Checking.\n"
<< "Enter S for Savings.\n"
<< "Enter R to Return to Main Menu.\n"
<< "Enter type and press Enter: ";
cin >> type;
do
{
switch(type)
{
case 'C':
system ("cls");
break;
case 'S':
system ("cls");
break;
case 'R':
menu();
break;
}
}while(type != 'R');
return type;
}
node * search_acctno(node *beg, int acctno)
{
node *curr = beg;
if(curr == NULL)
{
return NULL; //list empty
}
while(curr->acctno != acctno && curr->next != NULL)
{
curr = curr->next;
}
if(curr->acctno == acctno)
{
return curr; //return pointer to node
}
else
{
return NULL; // account not found
}
}
void balance(char &type, double ckbal, double svbal, ifstream &fin, node *&curr)
{
// Displays current balance on the screen
system("cls");
if (type == 'C')
{
fin >> curr->ckbal;
cout << "Checking Balance is: $"<< ckbal << endl;
}
else
{
fin >> curr->svbal;
cout << "Savings Balance is: $"<< svbal << endl;
}
return;
}
void deposit(char type, double &ckbal, double &svbal, ifstream &fin, node *&curr) // Processes a deposit
{
double amount; // Amount of deposit - assumes amount > 0
// Clear screen and get deposit amount
system("cls");
if (type == 'C')
{
fin >> curr->ckbal;
cout << "Amount of deposit?: ";
cin >> amount;
ckbal += amount;
cout << "Checking Balance is: $"<<ckbal<<endl;
}
else
{
fin >> curr->svbal;
cout << "Amount of deposit?: ";
cin >> amount;
svbal += amount;
cout << "Savings Balance is: $"<<svbal<<endl;
}
return;
}
void withdraw(char type, double &ckbal, double &svbal, ifstream &fin, node *curr) // Processes a withdrawal
{
double amount; // Amount of withdrawal - assumes amount > 0
// Clear screen and get withdrawal amount
system("cls");
if (type == 'C')
{
fin >> curr->ckbal;
cout << "Processing a Withdrawal\n";
cout << "Amount of withdrawal? ";
cin>>amount;
if(amount > ckbal)
{
cout << "Insuffienct funds!"<< endl;
}
else
{
cout << "Withdrawal amount? ";
cin >> amount;
ckbal -= amount;
cout << "Your checking balance is now $"<< ckbal << endl;
}
}
else
{
fin >> curr->svbal;
cout << "Processing a Withdrawal\n";
cout << "Amount of withdrawal? ";
cin >> amount;
if(amount > svbal)
{
cout << "Insuffienct funds!"<< endl;
}
else
{
cout << "Withdrawal amount? ";
cin >> amount;
svbal -= amount;
cout << "Your savings balance is now $"<< svbal << endl;
}
}
return;
}
void transfer(char type, double &ckbal, double &svbal, ifstream &fin, node *&curr)
{
double amount; //Amount of transfer - assumes amount > 0
system("cls");
if (type == 'C')
{
fin >> curr->ckbal;
cout << "Processing a Transfer\n";
cout << "Amount of transfer? ";
cin >> amount;
if(amount > ckbal)
{
cout << "Insuffienct funds!"<< endl;
}
else
{
ckbal -= amount;
cout << "Your checking balance is now $"<< ckbal << endl;
svbal += (ckbal - amount);
cout << "Your savings balance is now $"<< svbal << endl;
}
}
else
{
fin >> curr->svbal;
cout << "Processing a Transfer\n";
cout << "Amount of transfer? ";
cin >> amount;
if(amount > svbal)
{
cout << "Insuffienct funds!"<< endl;
}
else
{
svbal -= amount;
cout << "Your savings balance is now $"<< svbal << endl;
ckbal += (svbal - amount);
cout << "Your checking balance is now $"<< ckbal << endl;
}
}
return;
}