|
From: Vassili <v.v...@bt...> - 2001-07-21 08:30:03
|
This is the way I done it for my computeach course:
after getting the string I passed it to this function
unsigned calc_hash(char *reg)
{
char first_val, second_val[4];
int count;
unsigned value;
first_val =3D *reg; /* Store first character of regestration */
reg++;
/* Get the next three characters */
for(count =3D 0; count <=3D 2; count++, reg++)
second_val[count] =3D *reg;
second_val[3] =3D '\0'; /* Add null character */
value =3D first_val - 'A'; /* Subtract 'A' from the first character =
*/
value *=3D 1000; /* Multiply by number of records for each =
alpha character */
value +=3D atoi(second_val); /* Convert second_val to integer and =
add to value */
return value; /* return the hash */
}
hope this helps
Vas.
----- Original Message -----=20
From: Kei...@ao...=20
To: ":dev-cp"@lists.sourceforge.net=20
Sent: Friday, July 20, 2001 8:32 PM
Subject: [Dev-C++] Re C++
I am trying to write a program for vehicle registration ( a project =
for my=20
course in C programming) which takes a string of 1letter,3 digits, 3 =
letters(=20
UK number plate) using the 1st letter - 'A' * 1000 and the 3 digits =
to=20
produce a record number to locate the vehicle registration record. =
The file=20
is binary.=20
How can I take the registration number and convert it to the record =
number.=20
Thanks=20
Keith Lavington=20
|