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

This is a discussion on Is there any simple method to search whether a particular element is present in a vec within the C++ Programming forums, part of the General Programming Boards category; Is there any simple method to search whether a particular stringis present in a vector<string> v1?...

  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,893
    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,424
    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, 08:40 PM
  2. binary search and search using binary tree
    By Micko in forum C++ Programming
    Replies: 9
    Last Post: 03-18-2004, 09:18 AM
  3. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 09: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21