Noob needs help with macro
Hi, that's a small part of my code
Code:
#define PAIRSUM(d1, d2) (d1-48)*10+(d2-48) //macro at the top
while (element < 3)
{
printf("Please enter number your credit card number ");
scanf("%c%c%c%c%c%c%c%c%c%c", &d1[element], &d2[element], &d3[element], &d4[element], &d5[element],
&d6[element], &d7[element], &d8[element], &d9[element], &d10[element]);
sum_of_pairs[element] = PAIRSUM (d1[element],d2[element]) + PAIRSUM (d3[element],d4[element]) +
PAIRSUM (d5[element],d6[element]) + PAIRSUM (d7[element],d8[element]) + PAIRSUM (d9[element],d10[element]);
mod_result[element] = sum_of_pairs[element] % 26;
vchar[element] = 'A' + mod_result[element];
++element;
}
After first entry, everything is working fine and all results are good; however, every next input by the user for some reason decreases the input by 1 digit and messes up the results.
I'm pretty sure that when using arrays, the macro should be modified?
PS. arrays are just so I can print report of all input/results at the end.
Thanks in advance