searching in files
hey how do i search in a database file?
the thing is i have 2 databases one for parking records and the other for vehicle owners. I want the program, when the user inputs his plate number, to cross reference it and search for it in the vehicle owners database and see if it exists. If it doesnt i want to create it.
any help would be great.
It really depends on how the file is set up, but some sort of binary search would be my preference. Either load the entire file into memory, or set up a BTree type file structure that facilitates fast searching with the fewest file accesses. Another option if the file is well formatted is to open it as binary and use fseek/fsetpos to binary search by evaluating offsets and such.