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

访问char指针的不同方法有什么功能差异?

发布时间:2020-12-16 10:22:48 所属栏目:百科 来源:网络整理
导读:由于某种原因,我正在寻找的代码有很多类似的东西 char tmp [4]; 的memcpy(安培; TMP [0],foo_pointer,bar_size) 我本来希望的 char tmp [4]; 的memcpy(TMP,bar_size) 有没有什么理由让我在第一时间写作呢? 解决方法 不,他们是平等的. 即使没有看到tmp的定义
由于某种原因,我正在寻找的代码有很多类似的东西

char tmp [4];

的memcpy(&安培; TMP [0],foo_pointer,bar_size)

我本来希望的

char tmp [4];

的memcpy(TMP,bar_size)

有没有什么理由让我在第一时间写作呢?

解决方法

不,他们是平等的.

即使没有看到tmp的定义,前者也可能更清晰.

(并且只是为了让这个答案完整,为什么会这样,这里有一点来自标准草案的晚期:)

(6.3.2.1p3) Except when it is the operand of the sizeof operator,the _Alignof operator,or the
unary & operator,or is a string literal used to initialize an array,an expression that has
type “array of type” is converted to an expression with type “pointer to type” that points to the initial element of the array object and is not an lvalue. If the array object has register storage class,the behavior is undefined.

(编辑:李大同)

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

    推荐文章
      热点阅读