1. ## Structures, Arrays, Sums...

I was wondering if any one could help, point me in the right direction or offer any advice with my problem. The position within the file of the record is decided by this algorithm

result = data->vehicle_reg[0] - 'A';
/*First letter of the registration minus the int value of A */
position = (result *1000)+ data->vehicle_reg[1,2,3];
/*Result of first part mutiplied by 1000 and with the first
three digits of the registration added*/

So, for example
A122FFF would lead to the result of: 122

Data is a pointer to a structure, (I think) it's declared as below:-

struct car
{
vehicle_reg
etc.
} data;

2. You need to give more information to go on. How exactly does this translate to where in the file this records is stored? What position in the file does your example fall into, and why?

You need to provide more information. How many records are there total? Can they be added on a whim and if so, will they be automaticly sorted into the "correct" position in the file, updating all others? There is not enough to go on.

Quzah.

3. The 'position' generated is the files position, and where it will be written to, it's a random access file (Txt) and will contain 26000 records in total. The records are added only afte checking that a record does not exsist at the positon generated, if so the program will look for places after, the number...

4. > it's a random access file (Txt) and will contain 26000 records in
> total.

Ug. That's horrible.

Quzah.

5. Indeed...

So, can anyone help?

6. Don't mind helping, but the description of the algorithm is currently quite fuzzy, could you elaborate?

7. The algorithm is as follows:

The algortihm will take the integer value of the first character (of the registration), and subtract the integer character of 'A' from it and then multiply the result by 100. The next three digits are added to to give the record number.

For example "A122GFD"

'A' - 'A' = 0;
/*First letter of the registration minus the integer vaule of A*/

(0*1000) + 122 = 122
/*0 is the answer from the first part of algorithm, and the number 123 comes from the first three number of the registraion*/

8. Starting from
char vehicle_reg[4];

Which contains say
"A123"

Then it's
Code:
```result = (vehicle_reg[0] - 'A') * 1000 +
(vehicle_reg[1] - '0') * 100 +
(vehicle_reg[2] - '0') * 10 +
(vehicle_reg[3] - '0') * 1;```

9. Why thank you good Sir....

May you're jelly never fail to set properly...

10. ^--I think you ment jello, jelly doesn't really "set"

11. Excellent.

A flame war about Jello / Jelly.

::Sits back in chair with cold beer::

12. Never had jello... Had jelly... it sets in a way... starts as liquid, then gets to that wobbly 'set' phase...

But... If you're going to be so picky...

May you're toast always land butter side up....

13. *sits next to rob and passes the popcorn*

14. I hate Jello. specially the green Jello. People that eat Jello should all die. Why can't everyone understand that the blue Jelly is about 1000 times better. I rather eat worms then Jello.
Hey whos that?, on the chair drinking beer and eating popcorn?

15. Originally posted by Barjor
I hate Jello. specially the green Jello. People that eat Jello should all die. Why can't everyone understand that the blue Jelly is about 1000 times better. I rather eat worms then Jello.
Hey whos that?, on the chair drinking beer and eating popcorn?
Yeah. Jello is rather nasty. After all, it's made from the bones of horses which have been processed with acid. Just look up what gelatin is made from...

Quzah.