Find values in vector and create new vector

I have two vectors (secid (string) and close (double)). The program must read a value that the user inputs for secid and find the close values associated with that secid. Example data below.

secid close
1 10.1
5 11.7
3 5.5
1 10.8
8 5.4
1 2.3
1 4.1
6 1.9

Currently I can find the first instance of the secid and output the close for that single instance. I would like for the program to output all of the instances for that secid. Can anybody help?! My code currently is shown below:

double find_secid(vector<string> secid_v, vector<double> close_v, string secid)
{
for (int i=0; i<secid_v.size(); i++) {
if(secid.compare(secid_v[i])==0){
return close_v[i];
}
}
//if cannot find
return -1;
}

int main()
{
string inputsecid;
double temp = 0;
cout<<"please enter secid"<<endl;
while (cin>>inputsecid) {
temp = find_secid(secid,close,inputsecid);
if (temp==-1) {
cout<<"Not a real secid"<<endl;
}else{
cout<<"close"<<temp<<endl;
}
}
return 0; // program end
}
Topic archived. No new replies allowed.