I’m getting some very strange behaviour using the following switch statement:
string recognise_mti(int mti_code)
{
switch(mti_code)
{
case 1100:
case 1101:
return (mti_code + " (Auth. Request/Repeat)"); break;
default:
return (mti_code + " (NOT RECOGNISED)"); break;
}
}
It seems to return all sorts of things depending on the input integer. It’s probably going to turn out to be a silly mistake but as of yet, I’m unable to recognise it. Appreciate any help.
Neither
mti_codenor" (Auth. Request/Repeat)"is astd::string. So in fact, all that addition is going to do is pointer addition. So you’ll end up with a somewhat random (and probably invalid) pointer, which is then implicitly converted to astd::string.Try this: