Hello all,
I want to change the following code to have the user enter ANY NAME to see if the person is present in the array. I'v been trying for a couple hours now but keep getting errors. There's more to this problem but I have to get past this hurdle... Please help. Thank You.
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
int main()
{
string myStudents[3];
//this first part works. It stores names. I will change the loop later to do 100..
for(int counter = 0; counter <3; counter++)
{
cout <<"Enter student number " << counter+1 << " name: ";
cin>>myStudents[counter];
cout << endl;
}
// I use a specific name here. I need to change this so that I can cin any name for search.
bool isAndy = false;
for(int counter = 0; counter <3; counter++)
{
if (myStudents[counter] == "Andy")
{
isAndy = true;
}
}
if(isAndy == true)
{
cout<<"Yes, Andy is in Class"<<endl;
}
else
{
cout<< "No, Andy is not in Class" <<endl;
}
system ("pause");
return 0;
}