Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否有任何文档指定应用于 C 中文字的指针转换的含义?
例如:
int *my_pointer = (int *) 9
这是依赖于编译器还是标准的一部分?
编辑:根据以下评论删除误导性注释,谢谢。
这并不指向文字9。它将文字转换9为指向int. C 表示从整数到指针类型的转换是实现定义的。
9
int
int *my_pointer = &(int) {9};
这样做。它my_pointer指向一个int有价值的对象9。
my_pointer
指向整数的指针和整数到指针的转换是实现定义的(参见 C 标准的附件 J)。