I'm currently getting a fatal error LNK1120: 1 resolved externals. Can somebody help me figure out what is going on?
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
const int MAXCHAR = 101;
const int CAP = 100;
struct Cart
{
char itemName[MAXCHAR];
char itemPrice[MAXCHAR];
char itemTotal[MAXCHAR];
};
void menu();
char getCommand();
void exeCommand(Cart [], int &, char);
void addItem(Cart [], int &);
void showList(Cart [], int &);
void findCart(Cart [], int &);
void loadData(Cart [], int &);
void addItem(ifstream &, Cart [], int &);
void saveData(Cart [], int &);
int main(void)
{
Cart shopping[CAP];
int size = 0;
char option;
loadData(shopping, size);
do
{
menu();
option = getCommand();
exeCommand(shopping, size, option);
}while(tolower(option) != 'q');
}
void menu()
{
cout << "Welcome to Smart Shopping Cart! :\n"
<< "(a) to add an item\n"
<< "(s) to show the items list\n"
<< "(f) to find an item by item name\n"
<< "(q) to quit\n";
cout << "Please enter an option: ";
}
char getCommand()
{
char ans;
cin.get(ans);
switch (tolower(ans))
{
case 'a':
case 's':
case 'f':
case 'q':
cin.ignore(100, '\n');
return ans;
default:
cout << "Illegal input.";
cin.clear();
cin.ignore(100, '\n');
system("cls");
menu();
return getCommand();
}
}
void exeCommand(Cart list[], int &size, char ans)
{
switch(tolower(ans))
{
case 'a':
addItem(list, size);
saveData(list, size);
break;
case 's':
showList(list, size);
break;
case 'f':
findCart(list, size);
break;
case 'q':
cout << "Thanks for using Smart Shopping Cart. Goodbye!" << endl;
return;
default:
return;
}
}
void loadData(Cart list[], int &size)
{
ifstream inFile;
inFile.open("ShoppingCart.txt");
if(!inFile)
{
cout << "File did not open! Program terminating!" << endl;
exit(1);
}
while(!inFile.eof())
{
addItem(inFile, list, size);
}
}
void addItem(Cart list [], int &size)
{
char name[MAXCHAR];
char itemPri[MAXCHAR];
char total[MAXCHAR];
char junk;
cout << "Enter item Name (less than 101 characters.): ";
cin.get(name, MAXCHAR, '\n');
cin.get(junk);
cout << "Enter item price (less than 101 characters.): ";
cin.get(itemPri, MAXCHAR, '\n');
cin.get(junk);
cout << "Enter item price (less than 101 characters.): ";
cin.get(total, MAXCHAR, '\n');
cin.get(junk);
strcpy_s(list.itemName, name);
strcpy_s(list.itemPrice, itemPri);
strcpy_s(list.itemTotal, total);
size++;
}
void addItem(ifstream &inFile, Cart list[], int &size)
{
inFile.get(list.itemName, MAXCHAR, ';');
inFile.ignore(50, ';');
inFile.get(list.itemPrice, MAXCHAR, ';');
inFile.ignore(50, ';');
inFile.get(list.itemTotal, MAXCHAR, ';');
inFile.ignore(50, '\n');
size++;
}
void showList(Cart list[], int &size)
{
int i;
for(i = 0; i < size; i++)
{
cout << left << list.itemName << ";"
<< left << list.itemPrice << ";"
<< left << list.itemTotal << endl;
}
}
void saveData(Cart list[], int &size)
{
int i = 0;
ofstream outFile;
outFile.open("ShoppingCart.txt");
if(!outFile)
{
cout << "File did not open! Program terminating!" << endl;
exit(1);
}
for(i = 0; i < size; i++)
{
outFile << list.itemName << ';'
<< list.itemPrice << ';'
<< list.itemTotal << endl;
}
}
void findCart(Cart list[], int &size)
{
int i = 0;
char junk;
char shopping[MAXCHAR];
cout << "This will allow you to search for an item in a shopping cart." << endl;
cout << "Enter Item Name (less than 101 characters.): ";
cin.get(shopping, MAXCHAR, '\n');
cin.get(junk);
if (strcmp(list.itemName, shopping) == 0)
cout << "found it";
}