Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/56.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C 为什么海湾合作委员会;需要一个表达式“quot;”;?_C_Expression - Fatal编程技术网

C 为什么海湾合作委员会;需要一个表达式“quot;”;?

C 为什么海湾合作委员会;需要一个表达式“quot;”;?,c,expression,C,Expression,主服务器不知道您的功能。将功能偏差移到主设备上方或将其原型移到主设备之前: prog.c: In function ‘main’: prog.c:10: warning: implicit declaration of function ‘corners’ prog.c: In function ‘corners’: prog.c:15: error: expected expression before 主服务器不知道您的功能。将功能偏差移到主设备上方或将其原型移到主设备之前: prog.

主服务器不知道您的功能。将功能偏差移到主设备上方或将其原型移到主设备之前:

prog.c: In function ‘main’:
prog.c:10: warning: implicit declaration of function ‘corners’
prog.c: In function ‘corners’:
prog.c:15: error: expected expression before 

主服务器不知道您的功能。将功能偏差移到主设备上方或将其原型移到主设备之前:

prog.c: In function ‘main’:
prog.c:10: warning: implicit declaration of function ‘corners’
prog.c: In function ‘corners’:
prog.c:15: error: expected expression before 

您正在尝试使用初始化器表达式作为赋值。即使在C99中,这也是无效的,因为_角点的类型是
int*
,而不是
int[4]
。在这种情况下,最好分别为每个元素赋值。

您尝试使用初始化器表达式作为赋值。即使在C99中,这也是无效的,因为_角点的类型是
int*
,而不是
int[4]
。在这种情况下,最好单独分配每个元素。

语法是数组初始化,而不是赋值。我手边没有标准的副本,所以我无法引用章节,但你想说:

int corners (int array[rows][cols], int the_corners[NUM_CORNERS]);

我还随意将
int corners
更改为
void corners
,因为您没有返回任何内容。你的
main
也需要一个返回值,而你忘记了
#include
这个
语法是数组初始化,而不是赋值。我手边没有标准的副本,所以我无法引用章节,但你想说:

int corners (int array[rows][cols], int the_corners[NUM_CORNERS]);
我还随意将
int corners
更改为
void corners
,因为您没有返回任何内容。你的
main
也需要一个返回值,而你忘记了
#include

试试这个:

void corners (int array[rows][cols], int the_corners[]) {
    the_corners[0] = array[0][cols-1];
    the_corners[1] = array[0][0];
    the_corners[2] = array[rows-1][0];
    the_corners[3] = array[rows-1][cols-1];
}
#包括
#定义NROWS 2
#定义N列2
#定义NCORNERS 4
int角(int(*arr)[NCOLUMNS],int*_角);
int main(){
int i;
内切角[n角];
int arr[NCOLUMNS][NROWS]={{1,2},{3,4};
角(arr、_角);
对于(i=0;i
您可以阅读有关将2D数组传递给函数的内容。

尝试以下方法:

void corners (int array[rows][cols], int the_corners[]) {
    the_corners[0] = array[0][cols-1];
    the_corners[1] = array[0][0];
    the_corners[2] = array[rows-1][0];
    the_corners[3] = array[rows-1][cols-1];
}
#包括
#定义NROWS 2
#定义N列2
#定义NCORNERS 4
int角(int(*arr)[NCOLUMNS],int*_角);
int main(){
int i;
内切角[n角];
int arr[NCOLUMNS][NROWS]={{1,2},{3,4};
角(arr、_角);
对于(i=0;i

您可以阅读有关将2D数组传递给函数的内容。

请将代码粘贴到此处,而不是使用外部链接。我建议您对所有
#define
常量使用大写。人们通常不希望小写的东西-尤其是如果它们不是函数-成为预处理器宏/常量。明白了-…这对C有什么帮助?请将代码粘贴到这里,而不是使用外部链接。我建议您对所有
#define
常量使用大写。人们通常不希望小写的东西-特别是如果它们不是函数-成为预处理器宏/常量。明白了-…这对C有什么帮助?好吧,那没什么用。。。。它仍然希望在
{
标记之前有一个表达式好吧,这没什么作用……它仍然希望在
{
标记之前有一个表达式我删掉了include,因为我包含了我自己的一个包含stdio的库。h@tekknolagi:很公平,我只是认为您没有启用所有编译器的警告标志(或者我们忽略了同样糟糕的警告)并且可能错过了缺少的include。我删掉了include,因为我包含了一个包含stdio的我自己的库。h@tekknolagi:很公平,我只是认为您没有启用所有编译器的警告标志(或者忽略了同样糟糕的警告)而且可能错过了丢失的数据。