Although while (!!fin) should be equivalent to while (fin)
there are other problems with this code.
At lines 13-15 there is this:
13 14 15
fin >> key;
however there is no check after line 13 to see whether or not the input was successful. For example when the end of the stream is reached it will fail.
A usual alternative is this:
1 2 3 4 5
while (fin >> key)
if (key=="") continue;
Of course if you are not the author of the code then who knows...
Actually, i see the difference now. In the original code, string key is defined inside the loop, that means it will be initialised as an empty string. When the input fails, the string will be empty. But if defined before the loop, then key could retain some previous value. However in my suggested version, the body of the loop will never be entered unless the input was successful, so there's no need to be concerned about the case where key == "", that code can now be omitted. So the code simplifies to