This is C++, there's no need for an "equivalent" function.
You see, strncmp() exists because in C, character arrays decay to pointers, and pointers don't know the length of the array they're coming from -- or even if they're coming from an array in the first place.
In C++ you have std::string, use it instead of char.
You could compare initial substrings. Do you have an actual use case for these three-way comparisons, though? In C, there is no other choice, but in C++, I don't think I've ever used string::compare().
Catfish3.. ok so please tell me the function I should use instead of strncmp which I have used in C
Cubbi.... I didnt get the use of lexicographical_compare()
I was talking about compare function which you can see http://www.cplusplus.com/reference/string/string/compare/
on this link...
string::compare is a three-way comparison function: it returns one of three possible outcomes. In most cases (branching, looping, sorting with std::sort(), etc), we only need to know one of the two possible outcomes, in which case simple operators (==, <, !=, >=, etc) provide more clarity. Hence the question: what is your use case?