相关疑难解决方法(0)

在条件中使用数组

我想检查条件中的数组.我们来看下面这个简单的代码:

#include <stdio.h>
int main()
{
    int array[] = {1,2,3,4,5}; // initializing an array
    if(array[] == {1,2,3,4,5}) // using as condition
    {
         printf("worked");
    }
    else printf("not worked");

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

但它给出了一个错误:

In function 'main':|
C:\Python32\Untitled4.c|5|error: expected expression before ']' token|
||=== Build finished: 1 errors, 0 warnings ===|
Run Code Online (Sandbox Code Playgroud)

那么我应该如何在条件中使用数组呢?

c arrays

3
推荐指数
2
解决办法
5412
查看次数

标签 统计

arrays ×1

c ×1