M
muser
How can I pass the parameter " long part_num[6], into a case
statement. Case statement follows the function CheckDigit.
i.e. CheckDigit( something, temp1 );
Thank you for your help in advance.
bool CheckDigit(long part_num[6], char* record)
{
int weightingfactor;
int remainder;
int weightitem1, weightitem2, weightitem3, weightitem4, weightitem5;
int product;
int Mod11 = 11;
int checkdigit;
char partnum[6];
strncpy(partnum, &record[7], 6);
partnum[6] = '\0';
part_num[6] = atol( partnum );
weightingfactor = 6;
weightitem1 = (part_num[1] * weightingfactor);
weightingfactor = 5;
weightitem2 = (part_num[2] * weightingfactor);
weightingfactor = 4;
weightitem3 = (part_num[3] * weightingfactor);
weightingfactor = 3;
weightitem4 = (part_num[4] * weightingfactor);
weightingfactor = 2;
weightitem5 = (part_num[5] * weightingfactor);
product = (weightitem1 + weightitem2 + weightitem3 + weightitem4 +
weightitem5);
remainder = (product % Mod11);
checkdigit = (Mod11 - remainder);
if(!part_num[6] == checkdigit)
return false;
return true;
} case 'i':
case 'I':
case 'r':
case 'R':
ProcessIRecord( prnfile, temp1 );
CheckDigit( temp1 );
break;
statement. Case statement follows the function CheckDigit.
i.e. CheckDigit( something, temp1 );
Thank you for your help in advance.
bool CheckDigit(long part_num[6], char* record)
{
int weightingfactor;
int remainder;
int weightitem1, weightitem2, weightitem3, weightitem4, weightitem5;
int product;
int Mod11 = 11;
int checkdigit;
char partnum[6];
strncpy(partnum, &record[7], 6);
partnum[6] = '\0';
part_num[6] = atol( partnum );
weightingfactor = 6;
weightitem1 = (part_num[1] * weightingfactor);
weightingfactor = 5;
weightitem2 = (part_num[2] * weightingfactor);
weightingfactor = 4;
weightitem3 = (part_num[3] * weightingfactor);
weightingfactor = 3;
weightitem4 = (part_num[4] * weightingfactor);
weightingfactor = 2;
weightitem5 = (part_num[5] * weightingfactor);
product = (weightitem1 + weightitem2 + weightitem3 + weightitem4 +
weightitem5);
remainder = (product % Mod11);
checkdigit = (Mod11 - remainder);
if(!part_num[6] == checkdigit)
return false;
return true;
} case 'i':
case 'I':
case 'r':
case 'R':
ProcessIRecord( prnfile, temp1 );
CheckDigit( temp1 );
break;