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

[ad_1]

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);

[ad_2]

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