In decodify you have an empty string. You attempt to modify nonexistent elements of that empty string, resulting in undefined behavior.
In read_userpassword you have an empty vector. You attempt to modify nonexistent elements of that empty vector, resulting in undefined behavior.
Avoid undefined behavior.
Now, if the input is correct, I get false. Any idea?
Yes. Debug your code. Test your functions. Preferably before you start plugging them in to other code.
Presumably there is a function codify
somewhere that does the opposite of decodify
std::string s("somepwval59") ;
std::string decodified = decodify(codify(s)) ;
if ( decodified != s )
std::cout << '"' << s << "\" is not equal to \"" << decodified << "\"\n" ;
std::cout << "equal\n" ;
produce the expected value of equal
You might find http://www.slideshare.net/JonJagger/larry-and-jen-do-roman-numerals-in-c
to be of interest.
Last edited on
Haha, I got a broken gdb or anything like that. I'll test your code.