Thread: searching in files

  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    1

    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.

  2. #2
    Open to suggestions Brighteyes's Avatar
    Join Date
    Mar 2003
    Posts
    204
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Doxygen failing
    By Elysia in forum A Brief History of Cprogramming.com
    Replies: 19
    Last Post: 04-16-2008, 01:24 PM
  2. Multiple Cpp Files
    By w4ck0z in forum C++ Programming
    Replies: 5
    Last Post: 11-14-2005, 02:41 PM
  3. Folding@Home Cboard team?
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 398
    Last Post: 10-11-2005, 08:44 AM
  4. Searching txt files (another file i/o qn)
    By Catif in forum C++ Programming
    Replies: 9
    Last Post: 05-13-2002, 04:14 PM
  5. displaying text files, wierd thing :(
    By Gades in forum C Programming
    Replies: 2
    Last Post: 11-20-2001, 05:18 PM