This solution does not sit well with me. It looks like you're doing too much: checking how to take the input, taking input, and then checking whether that input worked all at once.
Before looking at the code, though, it's worth asking whether this is really the interface that you want to provide to the user. The way you've designed it, it looks like it is meant to be run by a human, as the requests for input will only muddle the output in a script. Furthermore, spell-checkers are usually non-destructive: running it with the wrong input file or the wrong dictionary file shouldn't lose you any data.
All in all, this makes double-checking with the user whether the dictionary file is correct questionable. It is also inconsistent: you do validate the input in that case, but don't in the case that both files are provided, so the user has to remember that if he intends to rely on the input being checked.
My first suggestion is thus to change your interface: only prompt for things that are not already provided, and if you detect an error, report it and exit.
Now to the code: you have a few cases where the program can go in an infinite loop. This happens if the user closes std::cin
, or if the user provided two filenames via argv
and then at least one failed to open: you'll keep trying to open it and filesOpen
will never be true.
Secondly, you're using operator>>
in most places, but use std::cin.get()
to ask the user whether he's sure. This will likely break if the user provides one command-line argument and then some file fails to open.
Thirdly, the condition of your loop seems strange to me. Why use an extra bool
that you then set at the very end instead of using break
or return
to get out of the loop, or, better, checking the condition directly? You can use a do-while loop if you want to save yourself one check, though I wouldn't bother as the performance effect will be negligible, while the code will be clearer.
MixingAs for the switch construct: I'd use a helper function or two instead. The code is sufficiently small for it to be clear, especially with the comment, but I don't think it wins you anything over two function calls. In general, the function looks too big to me, but I've already covered that above.
Last and least, mixing std::printf
and std::cin
is strange. I can't come up with any technical problems, but mixing two styles without a good reason is generally more trouble than it's worth.