char conversion problem
From: muser (charlie12345_at_hotmail.com)
Date: 12/17/03
- Next message: John Carson: "Re: member to pointer conversions - mommy look what I found"
- Previous message: tom_usenet: "Re: Respecting the standard"
- Next in thread: Joe C: "Re: char conversion problem"
- Reply: Joe C: "Re: char conversion problem"
- Reply: Victor Bazarov: "Re: char conversion problem"
- Reply: Karl Heinz Buchegger: "Re: char conversion problem"
- Reply: Jerry Coffin: "Re: char conversion problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 17 Dec 2003 10:08:51 -0800
is string converted to its integer equivalent by minusing it by 48?
the function is suppose to check the fifth digit of struct member
using the formula contained within the function.
The function isn't doing that at the moment, hence this post and the
querie above. string must be of type char.
bool checkdigitforcustomercode( char* string )
{
int weightingfactor = 5;
int checkdigit;
int remainder;
int check1;
for(int i =0; i < 5; ++i)
check1 += (string[i] - 48) * weightingfactor;/* problem area */
weightingfactor --;
remainder = check1 % 11;
checkdigit = 11 - remainder;
for(i=4; i<=5; i++)
if(!string[i] == checkdigit)
return false;
if(checkdigit == 11){
checkdigit = 'X';
}
else
if(checkdigit = 10){
checkdigit = '0';
}
return true;
}
- Next message: John Carson: "Re: member to pointer conversions - mommy look what I found"
- Previous message: tom_usenet: "Re: Respecting the standard"
- Next in thread: Joe C: "Re: char conversion problem"
- Reply: Joe C: "Re: char conversion problem"
- Reply: Victor Bazarov: "Re: char conversion problem"
- Reply: Karl Heinz Buchegger: "Re: char conversion problem"
- Reply: Jerry Coffin: "Re: char conversion problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|