I'm validating the c_code i.e the 5th digit in a string, disregarding
the 1st character.
example of rec is c1234576 my name my address
The check digit has been verified and are all o.k but when
i run the program i get error in the code. Pls help, the code is
as below
Code:
void read_rec(void)
{
char str[107];
char temp[6], chk_digit;
int weights[] = {5, 4, 3, 2};
int total=0, value, rem, check_num,count;
while(fgets(str, 107, fp) != NULL)
{
strncpy(temp,str,6);
for(count=1; temp[count] !='\0'; count++)
putchar(temp[count]);
fflush(stdin);
for(count=1; count<5; count++)
{
value = temp[count] - '0';
total += value * weights[count];
}
rem = total % MODULUS - rem;
if( check_num < 10 )
chk_digit = check_num + '0';
else
if( check_num == 10 )
chk_digit = '0';
else
chk_digit = 'X';
if(str[5] != chk_digit)
fprintf(prn_ptr,"Error in code\n");
}
fflush(stdin);
fprintf(prn_ptr,"\f");
}
thank for your responds