Thread: Searching and Comparing Strings Using Parsing

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    72

    Searching and Comparing Strings Using Parsing

    How can i search nd compare strings using parsing

  2. #2
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,490
    i smell homework...

    google can provide many answers

  3. #3
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    Your question is a little vague... mind elaborating? This might help: http://www.tuxedo.org/~esr/faqs/smart-questions.html

    Also, post any code that's relevant to the question (eg. Attempts at it)

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    Without more details of what you want, we can't answer adequately. Here is a potential solution, however:
    Code:
    #include <iostream>
    #include <string>
    #include <cstdlib>
    
    namespace
    {
      const std::string to_find = "arbitrary pattern";
    }
    
    int main()
    {
      std::string search_buf;
      std::string::size_type found;
    
      // Fill search_buf with the data to search
    
      found = search_buf.find ( to_find );
      if ( found != search_buf.npos )
        std::cout<<"\""<< to_find <<"\" was found!"<<std::endl;
      else
        std::cout<<"\""<< to_find <<"\" was not found."<<std::endl;
    
      return EXIT_SUCCESS;
    }
    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. hashing & searching
    By Micko in forum C++ Programming
    Replies: 9
    Last Post: 03-16-2004, 06:20 AM
  2. Searching through strings...
    By C-Duddley in forum C Programming
    Replies: 1
    Last Post: 09-14-2001, 04:26 PM