vector operator [] not recognized as string

1
2
3
4
5
6
vector<string> messages;

messages.push_back("Hello!");

if(strcmp(messages[0],"JOIN_QUEUE") == 0){
}


Why doesn't strcmp work?
strcmp is for use with char arrays, not with strings.

If you're using strings, you don't need (or want) strcmp. Just use the == operator:

1
2
3
4
5
6
vector<string> messages;

messages.push_back("Hello!");

if(messages[0] == "JOIN_QUEUE"){
}
Perfect! Thanks!
Topic archived. No new replies allowed.