Thread: search algoritam

  1. #1
    Unregistered
    Guest

    search algoritam

    Hi!

    I have to write a program for searching addressbook. Structure looks like tihs:

    struct addressbook {
    char name[20];
    char surname[20];
    int telnumber;
    } m;

    When I enter *en* (or en*) search algoritam needs to search a file with data from structure. I have to enter *. Program needs to list results in another file, output.txt.

    Does anyone knows how to this?

    Thanks,

    sed

  2. #2
    Unleashed
    Join Date
    Sep 2001
    Posts
    1,765
    > Does anyone knows how to this?
    Google does.
    The world is waiting. I must leave you now.

  3. #3
    Microsoft. Who? MethodMan's Avatar
    Join Date
    Mar 2002
    Posts
    1,198
    I have seen many people respond to questions, with links to google. I just have to say that google is one of the best tools when you are stuck. It has everything!
    -MethodMan-

    Your Move:Life is a game, Play it; Life is a challenge, Meet it; Life is an opportunity, capture it.

    Homepage: http://www.freewebs.com/andy_moog/home.html

  4. #4
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,380
    You can read in the file in an array of structures. And then perform a search on the data on the pattern you want to find.

  5. #5
    Unregistered
    Guest
    Then we do not need this site! We have google for everything.
    Please don't send me link to google, I've already been there. I just need an idea how to solve this.

    sed

  6. #6
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    >I just need an idea how to solve this
    which bit of the puzzle do you want help with?

    You can't ask for everything to be done for you, just say which bit in particular you are having trouble understanding, and hopefully someone will give you some pseudo code or clues on how to do it.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  7. #7
    Unregistered
    Guest
    Well, I want to find, for example, word "Deana" in file book.txt. When I enter *ena* program needs to search file book.txt for name that has ena -> Deana, Beana, etc. How to write search algoritam for this?

  8. #8
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    strstr() will do for that (minus the asterisks). Look that one up, and see if you think so.

    (I presume you are not wanting help to read the data, only search it?).
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  9. #9
    Unregistered
    Guest

    Post

    > (I presume you are not wanting help to read the data, only search it?).

    Thank you!

    sed

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Logical errors with seach function
    By Taka in forum C Programming
    Replies: 4
    Last Post: 09-18-2006, 05:20 AM
  2. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  3. Tutorial review
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 03-22-2004, 09:40 PM
  4. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM