|
-
Dec 5th, 2002, 12:04 PM
#1
Thread Starter
Lively Member
Extracting Characters
Help!!!
char FormatID(unsigned char *pString, unsigned char *sStringOfChars)
{
int i;
int nChr;
int nTot;
int nDigit;
nTot = 0;
for (i = 0; i < 9; i++)
{
nChr = character i of pString
if (nChr > 0) nTot += (nChr * (23 - (i + 1)));
}
nDigit = (23 - (nTot % 23));
return character nDigit of sStringOfChars
}
Not done any C++ for years, cannot remember a thing (doh!).
Anyone help with the above two lines :
nChr = ...
return ...
-
Dec 5th, 2002, 12:12 PM
#2
Guru
Not sure exactly what the function is supposed to do, but in general:
Code:
c = SomeString[n]; // copies the n'th char of SomeString to c, where n is zero-based
-
Dec 5th, 2002, 01:31 PM
#3
Frenzied Member
This is like a checksum module. 
Try:
Code:
char FormatID(unsigned char *pString, unsigned char *sStringOfChars)
{
int i=0;
char *nChr;
int nTot=0;
for (nChr=pString,i=0; i<9;i++,nChr++){
if(*nChr) nTot+=(nChr*(23-(i + 1)));
}
return (char)(23-(nTot % 23));
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|