I have this array and i am asking the user to enter a string that is in array, but if the user doesn't enter a string that is not in the array i want to ask the user to reenter a string until the string is in the array.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
int size=2;
string array[size]={"dd", "BB"};
string w;
for (int i =0; i<size; i++)
{ cout << array[i]<<endl;
}
cout<"<Enter a string from above list"; <<endl;
getline(cin,w);
//the problem i am having
while(w != array)
{ cout<"<Enter a string from above list"; <<endl;
getline(cin,w); }
The problem is how do i check if the user input of the string is in the array. The while loop i didn't doesn't work so how can i do this.