Can you help with a for loop I am working on.....it is a mess...
I am having trouble implemting a function that I want to search a list and then replace a name in that list. What I have so far is so wrong at this point that I am lost on were to even start with correcting it...
It compiles but stops doing what I am asking it do at the seond if loop. From what I can tell my main areas of concern are my second nested if loop (can this even be done) and my the body of "if(input == 1).
cout << "Please enter the name you want to replace : " << flush;
cin >> find;
cout << endl << "Please enter the name you want to replace it with : " << flush;
cin >> replace;
list<Artist>::iterator iter ;
for(iter = myArtist.begin(); iter != myArtist.end(); iter++)
if ((*iter).getArtBandName() == find)
cout << "Would you like to replace" << (*iter).getArtBandName() << " with " << replace << endl;
cout << "Type 1 for Yes or 2 For No : " << flush;
cin >> input;
if (input == 1)
*iter = replace;
else if (input == 2)
cout << "Returning to Main Menu" << endl;
cout << "Invalid input : Returning to Main Menu" << endl;
Should I nest my if/else loop in a diffrent type of loop?
I am really confused on how I actually make the name change offical. Am I even on the correct track or should I just start from scratch?