Hey, everyone. I wrote this C++ program to convert Roman Numerals into Ordinary English ones. It works fine - but I have a few questions.
1. Can it be made more efficient because i've used simple logic but the result is that the program looks so ugly - line 52 streches so long and that makes the code look a little confusing to read.
2. Can you peek more than one letter ahead because the program, as it is - can not tell that IIIX is 7 and NOT eleven because it only peeks one letter ahead.
3. What is the difference between formatted and unformatted input and does it make a difference if you use one and not the other?
You can set up a string containing all the characters you want to test for and then simply see if your input character is contained in that string.
As each of your tests contains an increasing set of possibilities you can also make use of the offset feature of the find() function to include as many or as few of the characters as you need:
I suggest to use std::getline(std::cin, some_str);. With this you can read a whole line, and read ahead as much as you want. Do some searching on Google for , this algorithm could be shortened a lot.