flag=flag && check_digit(cKey[i],eKey(i));

See anything different between the first argument and the second?