X,Y在C函数中传递数组的大小 [英] X,Y passing size for the array in C function
问题描述
我声明了我的函数,我想从对角线[0] [0] ... [5] [5]和[0] [5] ... [5] [0]中找到最小值。
我有算法,但是我的问题是实际的函数头。
我在为函数创建正式参数时遇到了问题。
我知道我们必须至少传递 x [] [this]
数组的大小,但我尝试了各种组合,甚至是
double minimum(int size,double x [] [size]){...}
double minimum( double x [] [int size]){...}
调用:
minimum(10,x [] [10])
error:']'令牌之前的预期表达式`
第二种情况在函数声明中给出错误:
错误:在'int'之前的期望表达式
<有人可以告诉问题是什么(或问题)?
因此,指定<$ c $> double double(int rowsize,int size,double x [] [size]){...} code> rowsize 所以你是正确的。 I've declared my function where I want to find the minimum from diagonals [0][0] ... [5][5] and [0][5]... [5][0].
I have the algorithm but my problem is with the actual function header. I have problem with creating the formal arguments for the function.
I know that we have to pass at least The first case gives an error when calling: The second case gives an error in declaration of function: Can someone tell what the problem is (or problems are)? So specifying But here I guess it is square So you are correct in that. 这篇关于X,Y在C函数中传递数组的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
或简单的
是opt不过在这里,我想它是方形的
$ b size x size
,所以它会是
$ b double minimum(int size,double x [] [size]){...}
如何调用它?
minimum(10,x)
x[][this]
size of array to the function, but I tried various combinations, even double minimum(int size, double x[][size]){...}
double minimum(double x[][int size]){...}
minimum(10, x[][10])
error: expected expression before ']' token `
error: expected expression before 'int'
double minimum(int rowsize,int size, double x[rowsize][size]){...}
or simplydouble minimum(int rowsize,int size, double x[][size]){...}
rowsize
is optional.size x size
so it will bedouble minimum(int size, double x[][size]){...}
How to call it?
minimum(10,x)