your loop is doing too much work.
char codes[] = "qwertyuiop";
string dCode = "wtu"; // hard-code search value
for(int i = 0; i < dCode.size(); i++)
{
for(int j = 0; codes[j] != 0; j++)
{
if( dCode[i] == codes[j])
{
cout << codes[j-1];
break;
}
}
}
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343