I am a c++ beginner and am trying to write a program that will take a roman numeral and convert it into an arabic number (arabic numbers are the format of a number we use today). Validation is obviously a key factor in converting a roman numeral. For example - IIII is not a valid input (IV would be correct). I have seen a lot of if/if else statement examples of this program but that is not a very "elegant" way of writing the program and would contain a massive amount of statements.
I would like to search my string to find an invalid input (ex: IIII, VV, MI). I have set up a bool function to return the results - but for some reason I am always returning a false value when something like just "I" is entered. Any suggestions?
@L B - thanks again for your help. There are several rules to roman numerals. I think I can put them all into implementation if I can just figure out how to search the string to find if the sequence of characters are present. I have been searching and just came across string::copy - is that the right direction?
@L B - maybe I am not being clear on the part I am struggling with. I understand what all the things are that make the string invalid - what I can't figure out is how to search for those in the string. It appears that when I use m_inputString.find_first_of("IIII") it is recognizing each "I" as an invalid character instead of evaluating the string until it finds 4 in a row. Does that make sense?
@Everyone - thanks for all of your help. I ended up rewritting my code completely different, although not the way I wanted, in order to turn it in on time and be functioning.
After coming back to my code - I realized that my mistake was quite small. String::Find() was working the way I thought it should - I simply had a statement further down in my code that was find_first_of("IM") that was causing the problem. Since it was find first of - It was recognizing a simply "I" input as invalid.