本文介绍了如何从无效转换*回诠释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我有
int类型的= 5;
长B = 10;
INT COUNT0 = 2;
无效** args0;
args0 =(无效**)的malloc(COUNT0 *的sizeof(无效*));
args0 [0] =(无效*)及一个;
args0 [1] =(无效*)和b;
我怎样才能从ARGS [0]和args0 [1]回int和长转换?
例如:
INT C =(IM东西丢失)args0 [0]
长D =(IM东西丢失)args1 [0]
解决方案
假设你和放大器; A0和&放大器; B0被认为是与放大器A和和B,以及你的意思是args0 [1]设立长D,已存储的指针,在args0 [0]和指针args0 [1]为b。这意味着你需要将它们转换为正确的指针类型。
INT C = *((INT *)args0 [0]);
INT D = *((*长)args0 [1]);
if I have
int a= 5;
long b= 10;
int count0 = 2;
void ** args0;
args0 = (void **)malloc(count0 * sizeof(void *));
args0[0] = (void *)&a;
args0[1] = (void *)&b;
how can I convert from args[0] and args0[1] back to int and long?for example
int c=(something im missing)args0[0]
long d=(something im missing)args1[0]
解决方案
Assuming that your &a0 and &b0 are supposed to be &a and &b, and that you mean args0[1] for setting up long d, you have stored a pointer to a in args0[0] and a pointer to b in args0[1]. This means you need to convert them to the correct pointer types.
int c = *((int *)args0[0]);
int d = *((long *)args0[1]);
这篇关于如何从无效转换*回诠释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!