Error code that doesn't seem to make sense
Oct 6, 2015 at 11:47am UTC
when I attempt to put float with the information from the "in" file I get an error saying "no operator found which takes right-hand operand of type 'float'"
I know I've probably done something wrong, but I don't know what.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
int processEMPLOYEE(float * payVALUE, float * hoursWORKED, float * HOURLYwage, int * EMPnum)
{
ifstream in;
ofstream out;
in.open("in.txt" );
if (in.fail())
{
cout << "Cannot open input file." << endl;
system("pause" );
exit(1);
}
out.open("out.txt" );
if (out.fail())
{
cout << "Cannot open output file." << endl;
system("pause" );
exit(1);
}
int looper = 0;
while (looper <= 200)
{
in >> payVALUE >> hoursWORKED >> HOURLYwage >> EMPnum;
looper++;
}
return 0;
}
Oct 6, 2015 at 12:55pm UTC
The error doesn't say `float' but `float*'.
you are trying to read into a pointer
Oct 6, 2015 at 3:04pm UTC
okay, thanks for that.
Is there a way to change the pointer's value because when I change the file reading to
in >> pay >> hours >> wage >> EMP;
I get the issue of "float" can't be assigned to "float*"
Oct 6, 2015 at 3:10pm UTC
Change to:in >> *payVALUE >> *hoursWORKED >> *HOURLYwage >> *EMPnum; // Note: * is derefence in this context
Oct 6, 2015 at 3:26pm UTC
Thanks! just what I needed.
Oct 6, 2015 at 4:30pm UTC
¿so you only cared about the last values?
you are reading 201 registers each time overwritting the last one.
Topic archived. No new replies allowed.