c - 我在 C 中收到错误 C2440。无法从 int 转换为 int[][2]

标签 c

我在 C 中遇到错误 C2440。无法从 int 转换为 int[][2]

感谢任何帮助。

#include "stdafx.h"
#include "stdio.h"

#define MAXDATACOL 2

void EnterValues(int dataarray[][MAXDATACOL]);
int main(void)
{   
    int dataarray[][MAXDATACOL]=0;
    int i,j;
    int values;
}
void EnterValues(int dataarray[][MAXDATACOL])
{
    for(;;)
    {
        int i, j;
        printf( "enter the x and y values terminated by ctrl Z\n" );
        if( scanf( "%d%d", &dataarray[i], &dataarray[j] ) == EOF )
            break;
    }
}

最佳答案

int dataarray[][MAXDATACOL]=0;

你不能这样做,因为:

  • 0 是一个数字,而 dataarray 是一个数组(所以是数字的集合)
  • 您正在尝试修改超出范围的值。索引从 0 到 MAXDATACOL - 1
  • 您没有指定数组的维度之一

关于c - 我在 C 中收到错误 C2440。无法从 int 转换为 int[][2],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5451821/

相关文章:

c/c++ for循环条件语句

c - C中的动态字符串数组结构

c - 在 list 中使用 requireAdministrator 恢复为 Windows 程序中的普通用户?

c - 如何将整数作为命令行参数?

c - 仅将一个数组中的正偶数值存储到另一个数组中

c - Netbeans主函数使用外部汇编函数

C (gcc) 警告 : initialization from incompatible pointer type when calling pthread_cleanup_push()

c - 向下舍入浮点结果

c - 无法链接 Rcpp 的 cpp 文件中的相关头文件

android - 无法为 Android 编译 LKM