I am stuck on this program. Just requesting some guidance...a point in the right direction or some useful knowledge. I am trying to create a program that reads from a file...it contains 5 bank customer records with each line starting with the line number (starting with 1000) and followed by a first name, a last name, and a balance. The program is supposed to read from the file and list the info in four separte arrays. The starting address of any element in the account array can then be calculated as the address of the first record in the array + (account number - 1000) * sizeof(int). Usin this informatio, the program should request a user entered account number and display the corresponding name and account balance.
I think i'm close to getting the first part, but the second part...I don't know where to start.
my comments to start off with:
1. Where is the array, and what will it be an array of? (strings possibly?).
2. You need to open the file at least for reading.
3. You wont need to do any calculation like you have described to get the data out of the array. That calculation looks wrong anyway.
I feel as if I am getting close....can anyone see why I'm getting this error:
error C2784: 'bool std::operator <(const std::vector<_Ty,_Alloc> &,const std::vector<_Ty,_Alloc> &)' : could not deduce template argument for 'const std::vector<_Ty,_Ax> &' from 'std::string'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\vector(915) : see declaration of 'std::operator`<''
int main()
{
string filename = "Bank Record.txt";
const int MAXRECORDS = 5;
int acctNum[MAXRECORDS];
int name[MAXRECORDS];
int lastName[MAXRECORDS];
int balance[MAXRECORDS];
string account[1];
ifstream inFile;
int i;
inFile.open(filename.c_str());
if(inFile.fail())
{
cout << "\nFailed to pen the input file." << endl;
cout << "Make sure the file currently exists" << endl;
exit(1);
}