Please hepl me by completing vector's find function

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include<iostream>
#include<vector>
 
using namespace std;
vector <string> names;
 
//Getting the values from user for vector
void getNames(string tmp)
{
     while (true) 
     {
     cout << "Enter a name (quit to stop): ";
     cin >> tmp;
     cout<<endl;
                if (tmp == "quit") 
                break;
     names.push_back(tmp);
     }
}
//displaying Vector elements
void displayNames()
{
     for(int i=0;i<(names.size());i++)
             cout<<"string = "<<names.at(i)<<endl;
             cout<<endl; 
}
     //finding a specific element in vector
void findNames()
{
          string x,found;
          cout<<"please string to find";
          cin>>x;
          find(names.begin(), names.end(), x);
}    
//erasing specific element from vector 
void removeNames()
{
     displayNames();
     int index;
     cout<<"enter index to remove the element for vector";
     cin>>index;
     names.erase(names.begin()+(index-1));
     displayNames();
} 
//sorting vector elements list
void sortNames()
{
          sort (names.begin(), names.end());
          cout<<"Sorted Vector List is"<<endl;
          displayNames();          
}
main()
{
      //Declaration of a character type variable to for actions 
      char ch;
      //Declaration of string type varible to accept strings or elements for vector
      string tmp;
      getNames(tmp);
      //prompting the user to enter the choice to choose the action to be done on vector list
      cout<<"enter your choice"<<endl;
      cout<<"'s' for sort, 'd' for display, 'r' for remove, 'f' for find the string";
      cin>>ch;
      if(ch=='s')
                  sortNames();
      else if(ch=='d')
                  displayNames();
      else if(ch=='r')
                  removeNames();
      else if(ch=='f')
                  findNames();
      system("pause");
      
}


i just want to do that
user will enter a string to find and the findNames() function will diaplay that
string is found and at position of vector.
I want to display the position of founded string in the vectorlist
please help
thanks..
Topic archived. No new replies allowed.