How to compare two strings in c++?

coldplay.xixi
Release: 2020-06-30 09:20:43
Original
9832 people have browsed it

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.

How to compare two strings in c++?

#2. Next, define two string variables to save the judged string.

How to compare two strings in c++?

#3. Enter two strings and save them in variables s1 and s2.

How to compare two strings in c++?

#4. Compare the sizes of strings s1 and s2 and store them in variable j.

How to compare two strings in c++?

#5. Based on the value of the judgment result j, output the comparison result of the two strings.

How to compare two strings in c++?

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.

How to compare two strings in c++?

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!