c ++比较字符串是否相等
In this tutorial, we’ll learn methods to compare strings in C++. Consider a scenario wherein you are required to enter your name and password to login to a particular website. In such cases, at the back end, we need to build and script functions to check and compare the input string (login details) with the string stored in the data base.
在本教程中,我们将学习在C ++中比较字符串的方法。 考虑一种方案,其中要求您输入名称和密码才能登录到特定网站。 在这种情况下,在后端,我们需要构建和编写脚本函数,以检查输入字符串(登录详细信息)并将其与数据库中存储的字符串进行比较。
So, relating it here, in this article, will be understanding the Ways to compare string in C++ language.
因此,在本文中与此相关的将是理解在C ++语言中比较字符串的方法 。
在C ++中比较字符串的技术 (Techniques to Compare Strings in C++)
Strings in C++ can be compared using either of the following techniques:
可以使用以下两种技术之一来比较C ++中的字符串:
-
String strcmp() function 字符串strcmp()函数
-
In-built compare() function 内置compare()函数
-
C++ Relational Operators ( ‘==’ , ‘!=’ ) C ++关系运算符('==','!=')
1. C ++中的字符串strcmp()函数 (1. String strcmp() function in C++)
C++ String has got in-built functions to manipulate and deal with dat