strcmp 和 !strcmp的理解

strcmp

int main()
{
	char string1[] = "abc";
	char string2[] = "abc";
	char string3[] = "bcde";
	int a, b,c;
	a = strcmp(string1, string2);
	b = strcmp(string1, string3);
	c = strcmp(string3, string1);
	printf("%d %d %d", a, b,c);		//0  -1  1
	return 0;

}
		char string1[] = "abc";
		char string2[] = "abc";
		char string3[] = "bcde";
		int a, b, c;
		a = !strcmp(string1, string2);
		b = !strcmp(string1, string3);
		c = !strcmp(string3, string1);
		printf("%d %d %d", a, b, c);	// 1 0 0
		

==总结:==实际应用只需要 相等或者不相等 两种情况;所以用上“ ”比较多见

你可能感兴趣的:(C++小案例,c++,开发语言)