I have been writing a Loan Program that requires at one point to read a .txt file and create an array from the contents.
This part is nothing new to me. The problem I have is a single line of code and I cant figure
out how to make it work.
It has to do with adding two chars and a double to a single pointer in an array.
It uses a class.
I have yet to find code to do this properly.
Here is an sample of my code
int* readData(string fname, int & arrSz){
int* result = NULL;
arrSz = 0;
char f;
char s;
double bal;
// Create a file object and open the file
ifstream inStream;
inStream.open(fname.c_str());
// Only process file if opening it is successful
if(!inStream.fail()){
inStream >> arrSz;
result = new int[arrSz];
// Read file contents into result, now that size is known
//create results array
for(int i = 0; i < arrSz ; i++){
inStream >> f >> s >> bal;
result[i] = Customer(f,s,bal);
}
inStream.close(); //don't forget to close file
}
return result;
the problem comes with the result = Customer(f,s,bal) line
At the moment it only is set up like this for reference to what I want to do.
Class file and header files are separate.
The file that is read has a single number for the first line, to be read as arraySz
Then has each corresponding line as two Letters and a number.
If I have left any information out that is needed to help please clarify.