是什么(字符*)x或(无效*)z的意思吗? [英] What does (char *) x or (void *) z mean?
本文介绍了是什么(字符*)x或(无效*)z的意思吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道的char * X
表示字符指针,但我感到困惑的是什么(字符*)X
表示。
I know char *x
means a pointer to char, but I'm confused about what (char*) x
means.
推荐答案
这是一个演员。您指示编译器把 X
就好像它是一个的char *
,而不管其真正的类型。如果你真的知道自己在做什么的演员,才应使用。
It's a cast. You are instructing the compiler to treat x
as if it were a char *
, regardless of its real type. Casts should only be used if you really know what you are doing.
对于一些内置类型,编译器可以执行有意义的转换,例如转换一个双击
到 INT
按四舍五入,但对其他类型的,你可能不会得到你所期望的。
For some built-in types, the compiler may perform a meaningful conversion, e.g. converting a double
to an int
by rounding, but for other types you may not get what you expect.
这篇关于是什么(字符*)x或(无效*)z的意思吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文