Mar 9, 2014 at 1:44am UTC
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.
Mar 9, 2014 at 2:03am UTC
Now, if the input is correct, I get false. Any idea?
Mar 9, 2014 at 2:57am UTC
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 ;
Does
1 2 3 4 5 6 7 8 9 10 11 12
#include <iostream>
#include <string>
int main()
{
std::string s("somepwval59" ) ;
std::string decodified = decodify(codify(s)) ;
if ( decodified != s )
std::cout << '"' << s << "\" is not equal to \"" << decodified << "\"\n" ;
else
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 Mar 9, 2014 at 2:57am UTC
Mar 9, 2014 at 3:02am UTC
Haha, I got a broken gdb or anything like that. I'll test your code.