双**和双(*)的区别[2]用C [英] Difference between double ** and double (*)[2] in C

查看:118
本文介绍了双**和双(*)的区别[2]用C的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是双**和双(*)[2]。

之间的区别

如果我理解不错,双**是一个指向双指针,所以它可以是任何大小而的二维数组双(*)[2]是一个指向数组双[2]

所以,如果它是正确的,怎么能成功地传递给函数。

有关实例:

 无效pcmTocomplex(短*数据,双* OutM中[2])

如果我通过双(*)[2]作为一个参数,我有以下警告:

 警告:从兼容的指针类型传递'pcmTocomplex的论点2
注意:预计双**,但参数的类型为双(*)[2]

什么是通过双重正确的方式(*)[2]功能?

编辑:调用code

  fftw_complex *的; / *上的typedef双[2] * /
在=(fftw_complex *)fftw_malloc(的sizeof(fftw_complex)* 1024);pcmTocomplex(数据,);


解决方案

 无效pcmTocomplex(短*数据,双* OutM中[2])

这第二个参数,你在这个函数原型看出意味着双指针数组,而不是你想要什么实际。

 无效pcmTocomplex(短*数据,双(* OutM中)[2])

这应该如何看,如果你要喜欢,你所期望的。

What is the difference between a double ** and a double (*)[2].

If I understand well, a double ** is a pointer to a pointer of double, so it could be a 2D array of any size whereas double (*)[2] is a pointer to an array of double[2].

So if it is right, how can it be passed successfully to a function.

For instance in :

void pcmTocomplex(short *data, double *outm[2])

if I pass a double (*)[2] as a parameter, I have the following warning :

warning: passing argument 2 of ‘pcmTocomplex’ from incompatible pointer type
note: expected ‘double **’ but argument is of type ‘double (*)[2]’

What is the right way to pass a double (*)[2] to a function ?

EDIT : calling code

fftw_complex        *in;             /* typedef on double[2] */
in = (fftw_complex *) fftw_malloc(sizeof(fftw_complex) * 1024);

pcmTocomplex(data, in);

解决方案

void pcmTocomplex(short *data, double *outm[2])

This second parameter , you seen in this function prototype imply array of double pointers and not actually what you want.

void pcmTocomplex(short *data, double (*outm)[2])

This how it should look like if you want , what you expect.

这篇关于双**和双(*)的区别[2]用C的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆