c语言 strcmp函数
Hello, folks! In this article, we will be focusing on the working of the C++ strcmp function in detail.
大家好! 在本文中,我们将重点关注C ++ strcmp函数的详细工作。
C ++ strcmp()函数入门 (Getting started with C++ strcmp() function)
C++ strcmp() function is an efficient way to compare two strings lexiographically
.
C ++的strcmp()函数是比较两个串的有效方式lexiographically
。
The strcmp()
function compares two input strings in a lexicographic manner and returns an integer value based on the outcome of the comparison of the two input strings.
strcmp()
函数以字典方式比较两个输入字符串,并根据两个输入字符串的比较结果返回一个整数值。
By lexicographic comparison, we mean, that two strings are actually compared with their ASCII values of every character. If found same, zero is returned and the string is said to be equal.
通过词典比较,我们的意思是, 实际上将两个字符串与每个字符的ASCII值进行比较 。 如果发现相同,则返回零,并说该字符串相等。
Syntax:
句法:
strcmp(string1,string2)
Example:
例:
#include<stdio.h>
#include<string.h>
int main()
{
char str1[] = "Python";
char str2[] = "Python";
if(strcmp(str1, str2)==0)
printf("Strings are equal");