作为一个C#程序员对C有个问题很好奇

q199308040000 2018-03-06 11:47:13
就是我们都知道,C99以前C语言没有布尔类型,那么==运算符返回的到底是什么?
...全文
441 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
自信男孩 2018-03-08
  • 打赏
  • 举报
回复
==是判断符号,也是返回真或假。
paschen 2018-03-07
  • 打赏
  • 举报
回复
返回int类型: http://en.cppreference.com/w/c/language/operator_comparison The type of any relational operator expression is int, and its value (which is not an lvalue) is 1 when the specified relationship holds true and ​0​ when the specified relationship does not hold.
q199308040000 2018-03-07
  • 打赏
  • 举报
回复
引用 9 楼 super_admi的回复:
C#里面貌似也可以这么写吧?
这个真不行,bool和int没有转换
赵4老师 2018-03-07
  • 打赏
  • 举报
回复
赵4老师 2018-03-07
  • 打赏
  • 举报
回复
理解讨论之前请先学会如何观察! 计算机组成原理→DOS命令→汇编语言→C语言(不包括C++)、代码书写规范→数据结构、编译原理、操作系统→计算机网络、数据库原理、正则表达式→其它语言(包括C++)、架构…… 对学习编程者的忠告: 多用小脑和手,少用大脑、眼睛和嘴,会更快地学会编程! 眼过千遍不如手过一遍! 书看千行不如手敲一行! 手敲千行不如单步一行! 单步源代码千行不如单步Debug版对应汇编一行! 单步Debug版对应汇编千行不如单步Release版对应汇编一行! 不会单步Release版对应汇编?在你想单步Release版C/C++代码片断的前面临时加一句DebugBreak();重建所有,然后在IDE中运行。(一般人我不告诉他!单步类的实例“构造”或“复制”或“作为函数参数”或“作为函数返回值返回”或“参加各种运算”或“退出作用域”的语句对应的汇编代码几步后,就会来到该类的“构造函数”或“复制构造函数”或“运算符重载”或“析构函数”对应的C/C++源代码处。 VC调试时按Alt+8、Alt+7、Alt+6和Alt+5,打开汇编窗口、堆栈窗口、内存窗口和寄存器窗口看每句C对应的汇编、单步执行并观察相应堆栈、内存和寄存器变化,这样过一遍不就啥都明白了吗。 对VC来说,所谓‘调试时’就是编译连接通过以后,按F10或F11键单步执行一步以后的时候,或者在某行按F9设了断点后按F5执行停在该断点处的时候。
q199308040000 2018-03-07
  • 打赏
  • 举报
回复
谢谢大家,已经理解了
paschen 2018-03-07
  • 打赏
  • 举报
回复
引用 3 楼 q199308040000的回复:
[quote=引用 1 楼 paschen的回复:]返回int类型: http://en.cppreference.com/w/c/language/operator_comparison The type of any relational operator expression is int, and its value (which is not an lvalue) is 1 when the specified relationship holds true and ​0​ when the specified relationship does not hold.
那么再请教下,C语言可以写if(0)吗?[/quote] 可以啊,C和C++都可以
q199308040000 2018-03-07
  • 打赏
  • 举报
回复
引用 1 楼 paschen的回复:
返回int类型: http://en.cppreference.com/w/c/language/operator_comparison The type of any relational operator expression is int, and its value (which is not an lvalue) is 1 when the specified relationship holds true and ​0​ when the specified relationship does not hold.
那么再请教下,C语言可以写if(0)吗?
  • 打赏
  • 举报
回复
引用 3楼我是你的主体 的回复:
[quote=引用 1 楼 paschen的回复:]返回int类型: http://en.cppreference.com/w/c/language/operator_comparison The type of any relational operator expression is int, and its value (which is not an lvalue) is 1 when the specified relationship holds true and ​0​ when the specified relationship does not hold.
那么再请教下,C语言可以写if(0)吗?[/quote]可以 就是不执行下面的语句
maoge8888 2018-03-07
  • 打赏
  • 举报
回复
应该是0或者非0
super_admi 2018-03-07
  • 打赏
  • 举报
回复
C#里面貌似也可以这么写吧?

33,311

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 新手乐园
社区管理员
  • 新手乐园社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧