gpt4 book ai didi

C编程: How could you compare two types without ==

转载 作者:太空宇宙 更新时间:2023-11-04 05:20:50 24 4
gpt4 key购买 nike

我想知道 C 编译器将如何处理比较运算符“==”

我希望创建一个函数(在 C 中)来比较两个事物而不使用 ==。我认为可以通过使用按位运算符(&、|、^、>>)来完成一些操作,但是我似乎想不出该怎么做。

有人有想法吗?

谢谢!

最佳答案

这里有一个不使用 == 检查两个整数是否相等的简单方法:

int x = 3;
int y = 3;

if(x < y || y < x)
printf("Not equal");
else
printf("Equal");

关于C编程: How could you compare two types without ==,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9368113/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com