C编程中的(int)是什么意思
发布时间:2020-12-16 10:42:05 所属栏目:百科 来源:网络整理
导读:void problem3(void) { int overflowme[16]; int x = (int) problem3; // x is the address of the first instr for problem3 printf("hello worldn"); overflowme[17] = x; 我想知道(int)在C编程中做了什么. 解决方法 这是一个类型转换,告诉编译器“忽略问
void problem3(void) { int overflowme[16]; int x = (int) problem3; // x is the address of the first instr for problem3 printf("hello worldn"); overflowme[17] = x; 我想知道(int)在C编程中做了什么. 解决方法
这是一个类型转换,告诉编译器“忽略问题3真正具有的类型,并将其作为一个int类型处理”.
在此示例中,problem3具有函数指针类型,因此通常编译器将拒绝该程序(当期望整数时使用函数指针通常是程序员错误).类型转换强迫一种不同的解释 – 程序员踩着并说“我知道我在做什么”. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |