I'm trying to make three dynamic arrays whose indexes are determined by the number of lines in a text file. I then need to make their index values modifiable. I was thinking that global arrays would be my best bet.
For some reason I keep receiving the following compiler error: secondLab.obj : error LNK2019: unresolved external symbol "void __cdecl arrayInput(...)
Question, how do I fix this and basically meet the goal of my program.
Here's my code:
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <new>
using namespace std;
int INDEXES = 0;
string *names_Array = new string[INDEXES];
double *rates_Array = new double[INDEXES];
double *hours_Array = new double[INDEXES];
void subscript(ifstream&, int&, string&, double&, double&);
void arrayInput(istream&, string [], double [], double[],
string&, double&, double&);
int main ()
{
string names;
double rates;
double hours;
string filename("employee sample file.txt");
ifstream employeeInfo(filename.c_str());
if (employeeInfo.fail())
{
cout << "Sorry, file was not successfully opened. "
<< "Please make sure your file exists and\n"
<< "re-run the program." << endl;
}
subscript(employeeInfo, INDEXES, names, rates, hours);
arrayInput(employeeInfo, names_Array, rates_Array, hours_Array,
names, rates, hours);
cout << names_Array[0] << endl
<< names_Array[1] << endl
<< names_Array[2] << endl
<< names_Array[3] << endl
<< names_Array[4] << endl;
delete[] names_Array;
delete[] rates_Array;
delete[] hours_Array;
system("pause");
return 0;
}
void subscript(ifstream& employeeInfo, int& INDEXES,
string& names, double& rates, double& hours)
{
while(!employeeInfo.eof())
{
employeeInfo >> names >> rates >> hours;
INDEXES++;
}
}
void arrayInput(ifstream& employeeInfo, string names_Array[],
double rates_Array[], double hours_Array[], string& names, double& rates, double& hours)
{
int i = 0;
while(!employeeInfo.eof())
{
employeeInfo >> names >> rates >> hours;
names_Array[i] = names;
rates_Array[i] = rates;
hours_Array[i] = hours;
i++;
}
}