gpt4 book ai didi

c编程: what is the difference of the type conversions?

转载 作者:太空宇宙 更新时间:2023-11-04 00:12:37 25 4
gpt4 key购买 nike

给定以下 C 代码,a = f;a = (int *) f; 之间有什么区别?

float *f;
int *a;
...
a = f;
a = (int *) f;

最佳答案

float *f;
int *a;

a = f;

这个赋值是错误的(违反了 C 约束),指针类型之间没有隐式转换(void * 除外)。编译器可以拒绝编译带有此赋值的程序。

关于c编程: what is the difference of the type conversions?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19323947/

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