I'm fairly new to programming, and I'm wondering if there's any way I can compare a string input to an array element? I tried the code below, and I know it's wrong, I just don't know how else to go about this.
#include <iostream>
using namespace std;
int main()
{
string Username[10] = {"name1", "name2", "name3", "name4", "name5", "name6", "name7", "name8", "name9", "name10"};
string login;
int i;
cout << "Enter username login: ";
getline(cin, login);
cout << "\n";
for (i = 0; i < 10; i++)
if (login == Username[i])
{
cout << "Loading user settings...";
}
else
cout << "Error: Wrong username entered. ";
return 0;
}