I'm having a lot of issues getting the data from my input file, which is opened in main, to give the right input values. The input for the line to be read is:
10 0 S Y 100.00
I inserted a break point at the cout line, and the compiler told me the values were as follows, exactly:
a -858993460
b -858993460
c -52 '|'
d -52 '|'
e -107374176.
The incorrect data seems consistent by data type, but I haven't been able to do anything with that information. I also noted the '.' at the end of the float, but again, no options seem visible to me.
I also have a completely blank error file. The syntax for my data validation is the same, with different parameters. These errors are of course triggered by the ridiculous data I have, and have been every time I've done a test-run, but the error file itself is still empty.
The variable assignment at the end is unnecessary i think, but I was using that for debugging. I included it for variable context.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
void myInput(int & adults, int & children, char & type, char & wknd, float & deposit, int & billNumber)
{
int a, b;
char c, d;
float e;
ifstream inputFile;
ofstream error;
if (!inputFile)
{
error << "File could not be found.";
cout << "An error occured in. Please check error file." << endl;
}
inputFile >> a >> b >> c >> d >> e;
cout << a << ", " << b << ", " << c << ", " << d << ", " << e << endl;
adults = a;
children = b;
type = c;
wknd = d;
deposit = e;
|