Hello adelbak,
I need to ask you a question: Are you intending to increment twice the "i" variable in the for loop ?
the first for statement initialize i to 0 and j to 0 and an the end of the for loop, I can see is i++, which means, you are incrementing "i" by 1 and also, the for loop when it reaches the close brace "}" will also check for the condition if "i" still less than 15 , if that ok, also increment "i" again. So you are incrementing "i" twice . Also, I can see that you are incrementing "j" at the same time. My question is : Are you intentionally incrementing "i" twice ? if yes, then last "i++" should be removed and then the for loop at the beginning should be like this if I understood your code correctly:
int i=0, j=0;
//for (i=0, j=0; i < 15; i++, j++)
for (; i < 15;)
{
if (inp_imei[i] < '0' || inp_imei[i] > '9')
{
return 1;
}
out_imei[j] = (inp_imei[i] - '0');
if (i >= 14)
break;
if (inp_imei[i+1] < '0' || inp_imei[i+1] > '9')
{
return 1;
}
out_imei[j] += ((inp_imei[i+1] - '0') << 4);
out_imei[j] = out_imei[j] ^ out_mask[j];
//i++;
i+=2;
j++;
}
is that what you intended ? to increment "i" twice ? and "j" will be always incremented to 1 ?