I made this code where I would like to get a an output that would look like "book1 has this names that you entered: " and then list all the names in sequence that are matching for vector that was populated by user and array that was made at the beggining of the program.
I get an output for every name that is matched, instead of just one sentence with the list of names.
Thank you in advance!
string book1[3]= {"Victor", "Chuck", "Sam"};
string book2[3]= {"Suzy", "Tiffany", "Pam"};
for (vector<string>::iterator i = vect.begin();
i!= vect.end();
++i)
{ for (int b=0;b<3;b++)
{if (*i==book1[b])
{
cout<<"book1 has this names that you entered: " << *i <<endl;
}}
for (vector<string>::iterator i = vect.begin();
i!= vect.end();
++i)
{ for (int c=0;c<3;c++)
{if (*i==book2[c])
{
cout<<"book2 has this names that you entered: " << *i <<endl;
}}}
Before the for loop put cout << "book1 has this names that you entered: ";
Inside the for loop put cout << *i << ",";
After the for loop put cout << endl;