C++ strcmp() Function
C++ strcmp() function compares two strings and returns zero if they are same.
If length of s1 < s2, it returns <0 value.
If length of s1 > s2, it returns >0 value.
strcmp() function is case sensitive.

Syntax:
strcmp (char * s1, char * s2 );
Example:
#include <iostream> #include <cstring> using namespace std; int main () { char str1[30] = "Onlinetpoint"; char str2[30] = "Onlinetpoint"; if(strcmp(str1,str2)==0) { cout << "str1 & str2 both strings are equal"; } else { cout << "str1 & str2 both strings are not equal"; } return 0; }
Quickly Find What You Are Looking For
OnlineTpoint is a website that is meant to offer basic knowledge, practice and learning materials. Though all the examples have been tested and verified, we cannot ensure the correctness or completeness of all the information on our website. All contents published on this website are subject to copyright and are owned by OnlineTpoint. By using this website, you agree that you have read and understood our Terms of Use, Cookie Policy and Privacy Policy.