String value inside an array inside an if statement!

I'm trying to check if an element inside an array has a char/string value inside an if statement and I write:

1
2
3
4
5
6
string names[10] = {"name1","name2","name3","name4","name5"}
cout << "Enter a name in field 3:" << endl;
con >> names[3] = name;
if (names[3] == "David" && name == "David") {
cout << "field 3 has name David already..." << endl;
}

this is a stupid example but I just want to give you an idea, I want to check "word" value not an integer that is inside an array!

whenever I try my code above in line 4 I got an error message!
Last edited on
never mind, for some reason it worked now!
Thanks :)
Topic archived. No new replies allowed.