Thread: Is there any simple method to search whether a particular element is present in a vec

  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    24

    Question Is there any simple method to search whether a particular element is present in a vec

    Is there any simple method to search whether a particular stringis present in a vector<string> v1?

  2. #2
    Registered User
    Join Date
    Jan 2008
    Posts
    24
    Also how to get index number?
    i.e. I want to know at what location string "phone" is stored in vector<string> v1.
    How I will get that?
    Please help.

  3. #3
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Yes. Look at the functions in the <algorithm> header.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  4. #4
    Registered User
    Join Date
    Jan 2008
    Posts
    24
    Is there any such function available?

  5. #5
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    Look at this dictionary definition, and you will realise CornedBee has answered your question.

    Algorithm (n) : A finite set of unambiguous instructions performed in a prescribed sequence to achieve a goal, especially a mathematical rule or procedure used to compute a desired result. Algorithms are the basis for most computer programming.

  6. #6
    Registered User
    Join Date
    Jan 2008
    Posts
    24

    Smile Solved

    Thanks A Lot.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Tutorial review
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 03-22-2004, 09:40 PM
  2. binary search and search using binary tree
    By Micko in forum C++ Programming
    Replies: 9
    Last Post: 03-18-2004, 10:18 AM
  3. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM
  4. Binary searches
    By Prezo in forum C Programming
    Replies: 4
    Last Post: 09-10-2002, 09:54 PM
  5. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM