The basic concept of this code is that you take input from a .txt file about The type of operation you want to do, the first number and the second number (It's a calculator obviously). So if i write "Addition 2 3" It should output 5 to the output.txt file, but it prints some numbers and letters which i think its an address of some sort. how do i solve this? much thanks. This is the code (please don't mind that it's written in italian):
Thanks for your help everyone!
Ganado, why exactly do i put those while parameters? Whats the difference between putting those parameters on the while loop and using a while with !infile.eof() and with infile >> scelta >> num1 >> num2 inside?
Luca, you are slightly misquoting me: I said that you should put the [first] read statement in the while test. @Ganado's form is good here.
The problem with !infile.eof() is that this is NOT triggered by reading the last item, but by trying to read another one afterward. The end result is that a loop which shouldn't run actually does, the stream fails and what was previously in the input variable ends up being dealt with twice.