加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c – int(x)做什么?

发布时间:2020-12-16 10:25:42 所属栏目:百科 来源:网络整理
导读:我已经看过这些,看起来似乎是c代码中的函数,但我不知道它们做了什么或它们是什么,它们似乎做类似于类型转换的东西,但它们看起来不像是类型转换,所以它们是什么? 它们看起来像这样:int(x)其中x是一些数字输入,我一直在网上查看,但我无法找到任何关于它们的
我已经看过这些,看起来似乎是c代码中的函数,但我不知道它们做了什么或它们是什么,它们似乎做类似于类型转换的东西,但它们看起来不像是类型转换,所以它们是什么?

它们看起来像这样:int(x)其中x是一些数字输入,我一直在网上查看,但我无法找到任何关于它们的信息(可能是因为我不知道它们被称为什么) .

有帮助吗?

解决方法

这称为“功能表示法”,它是显式类型转换(“转换”)的一种形式. C 11,5.2.3:

5.2.3 Explicit type conversion (functional notation)

  1. A simple-type-specifier (7.1.6.2) or typename-specifier (14.6) followed by a parenthesized expression-list constructs a value of the specified type given the expression list. If the expression list is a single expression,the type conversion expression is equivalent (in definedness,and if defined in meaning) to the corresponding cast expression (5.4). If the type specified is a class type,the class type shall be complete. If the expression list specifies more than a single value,the type shall be a class with a suitably declared constructor (8.5,12.1),and the expression T(x1,x2,…) is equivalent in effect to the declaration T t(x1,…); for some invented temporary variable t,with the result being the value of t as a prvalue.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读