Thread: Searching for a list specific words in a string

  1. #1
    Registered User
    Join Date
    Jun 2005

    Question Searching for a list of specific words in a string


    I have a basic problem and am unsure of how to approach it best.

    I have a file which has a header of :
    I have read this file and saved it to a string called readfile.

    the second line also contains this data but the problem is that these words wont always appear in the same order so i need to search the first line (which is always in the right order) and assign tokens to each word.

    Then i want to search the second line for occurances of the word "hello" and give it the index of 1 as well.

    thus i can hypothetically construct a line of 1;2;3;4;5.

    i wanted to know that strtok seems to be the best way of doing it
    but how do i store the first line so that future lines in the file can use its index.

    all help will be appreciated
    Last edited by shoobsie; 04-26-2006 at 08:50 AM.

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #3
    Registered User
    Join Date
    Jun 2005
    Hi thanks for your reply.

    I decided on using strtok and comparing the input to a table of predefined values.

    thus i will be able to get the position in which they occur.

    I might need a bit of help for the next part so i will post it in a few hours.


  4. #4
    Registered User
    Join Date
    Feb 2006
    Great India
    Can you please post your original question ? I mean the same you are trying . It sounds interesting to work out. Please type out the original question.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OOP Question DB Access Wrapper Classes
    By digioz in forum C# Programming
    Replies: 2
    Last Post: 09-07-2008, 04:30 PM
  2. compiler build error
    By KristTlove in forum C++ Programming
    Replies: 2
    Last Post: 11-30-2003, 10:16 AM
  3. How can I traverse a huffman tree
    By carrja99 in forum C++ Programming
    Replies: 3
    Last Post: 04-28-2003, 05:46 PM
  4. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM