Here is my code for a calculator program. I'm very much unsure what is wrong with the code, it isn't functioning properly. I have an infile to read from. Also, the infile has fractional parts, so I would need to use float, but I have modulus in the code, how would I turn just the modulus into integer?
@lastchance, if you're speaking about the while(inf>>n1); the professor told us that if write it the way I have it, that it'll read the infile entirely.
@jonin, I assumed you could only have int mod not anything else. If I declare my variables as float/double then the mod portion will not run.
No @CodeNovice, I'm not speaking about your while() statement, I'm speaking about where you put your output line. Your code may or may not read the whole file, but it is only ever going to output the last result alone.
you can have floating point mod. Again, its the fmod function in <cmath>. It will run fine if you do that. % operator does NOT work: that is for integers. I find the concept odd and have only used it a time or two, but its there if you want it.
Are you sure that your input file has a genuine "minus" sign in and not one of the alternate bars that wordprocessors like to create? It is failing to read that.
I placed // on line 33 and 34, and the output is still the same. Something has to be wrong with the infile declaration? It isn't reading the data from it.
Please do what I asked, not something completely different. Once it fails to read a character then your program will end, irrespective of what you have commented out. If changing it to a + works then I should go back to your input file and manually edit it for a minus sign.
OKKK I have no idea what just happened. But for shits and giggles I went into the input data and changed line 2 from the '-' that was there to the '-' on my keyboard. Saved the alteration and re-ran the code. Once I opened my output file this appeared.
You know now that I think about it, I'm unsure what one would put, I'd normally say the value of which makes the inequality t/f. But for this it makes sense to have 1 or 0. What value do you think would make it easier to read?