Home > Article > Backend Development > How to compare two strings in c++?
Recommended tutorial: "C Video Tutorial"
c How to compare two strings?
c Method of comparing two strings:
1. First, define an integer variable j to save the result of the judgment.
#2. Next, define two string variables to save the judged string.
#3. Enter two strings and save them in variables s1 and s2.
#4. Compare the sizes of strings s1 and s2 and store them in variable j.
#5. Based on the value of the judgment result j, output the comparison result of the two strings.
6. Use the compare function to compare two strings. When s1 is greater than s2, the return value is greater than 0. When s1 is equal to s2, the return value is equal to 0. When s1 is less than s2 When the return value is less than 0.
Recommended related articles: "c#.net development graphic tutorial"
The above is the detailed content of How to compare two strings in c++?. For more information, please follow other related articles on the PHP Chinese website!