[Solved] Built in function to compare strings in C++?


You could use std::string::compare() which provides the same functionality as strcmp().

std::string name1 = "John";
std::string name2 = "Micheal";

int result = name1.compare(name2);

Would roughly be the same as:

const char* name1 = "John";
const char* name2 = "Micheal";

int result = std::strcmp(name1, name2);

solved Built in function to compare strings in C++?