本文介绍了struct my_struct * p =(struct my_struct *)malloc(sizeof(struct my_struct));的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 上面有什么问题? 别担心,我已经知道了(上周吸取了我的教训。)这是为了 我们常驻编译大师的好处似乎认为你需要演员。 我也这么认为,直到我开始在这里发帖! 谢谢, 克里斯 解决方案 更好的是,这是电子邮件本身。请帮忙! <开始发送电子邮件> 首先,在C和C ++中,必须使用void *进行强制转换。这是来自 你告诉我的相同原因:否则,如果编译器不知道知道指向的对象大小是多少,它可能会得到 与算术运算混淆。你可以问他从哪里学到了这个规则。告诉我你是否希望我直接与他对应。 其次,使用整数类型的地址而不是 void *的可能原因是为了对 地址执行按位运算,您必须使用整数类型的运算符。 < end email> 更好的是,这是电子邮件本身。请帮忙! <启动电子邮件> 首先,在C和C ++中,必须使用void *进行强制转换。这是来自 来自void *的转换在C ++中是必需的,而不是在C中。 你告诉我同样的原因:否则,如果编译器不会知道指向的对象大小是多少,它可能会与算术运算混淆。你可以问他从哪里学到了这条规则。告诉我你是否希望我直接与他对应。 其次,使用整数类型的地址而不是 void *的可能原因是为了对一个地方执行按位运算地址,你必须使用整数类型的运算符。< end email> Regis 演员。 更好的是,这是电子邮件本身。请帮忙! <启动电子邮件> 首先,在C和C ++中,必须使用void *进行强制转换。这是来自 来自void *的Casts在C ++中是必需的,而不是在C. 我知道...我正在钓鱼更多信息!也许如果我再次转发并且 说你错了我会得到更多... 你错了! 你告诉我的原因相同:否则,如果编译器不知道指向的对象大小是多少,它可能会与算术运算混淆。你可以问他在哪里 从这里学到了这条规则。告诉我你是否希望我直接与他对应。 其次,使用整数类型表示地址而不是而不是void *的可能原因是为了对我执行按位运算地址,你必须使用整数类型的运算符。< end email> Regis What is wrong with the above?Don''t worry, I already know (learned my lesson last week.) It is for thebenefit of our resident compiler guru who seems to think you need the cast.I thought it too, up until I started posting here!Thanks,Chris 解决方案Even better, here is the email itself. Please help!<start email>First, Casts from void * are necessary both in C and C++. This is from thesame reason you told me: otherwise, if the compiler wouldn''tknow what is the size of the object which is pointed at, it might getconfused with arithmetic operations. You can ask him where did he learnedthis rule from. tell me if you want me to correspond directly with him.Second, a possible reason to use integral types for addresses rather thanvoid *, is that in order to perform bitwise operations on anaddress, you have to use operators of an integral type.<end email> Even better, here is the email itself. Please help! <start email> First, Casts from void * are necessary both in C and C++. This is from theCasts from void* are necessary in C++, not in C. same reason you told me: otherwise, if the compiler wouldn''t know what is the size of the object which is pointed at, it might get confused with arithmetic operations. You can ask him where did he learned this rule from. tell me if you want me to correspond directly with him. Second, a possible reason to use integral types for addresses rather than void *, is that in order to perform bitwise operations on an address, you have to use operators of an integral type. <end email>Regis cast. Even better, here is the email itself. Please help! <start email> First, Casts from void * are necessary both in C and C++. This is fromthe Casts from void* are necessary in C++, not in C.I am aware... I''m fishing for more info! Perhaps if I reposted again andsaid you were wrong I''ll get more...You''re WRONG!learned this rule from. tell me if you want me to correspond directly with him. Second, a possible reason to use integral types for addresses ratherthan void *, is that in order to perform bitwise operations on an address, you have to use operators of an integral type. <end email> Regis 这篇关于struct my_struct * p =(struct my_struct *)malloc(sizeof(struct my_struct));的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-19 23:27