gpt4 book ai didi

c++ - 动态分配一个二维数组

转载 作者:行者123 更新时间:2023-11-28 03:34:35 25 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
How do I use arrays in C++? (FAQ)
Using dynamic multi-dimensional arrays in c++

void fillTestCase (int * tC)
{
ifstream infile;
infile.open("input00.txt",ifstream::in);
int * tempGrid;
int i,j;
infile >>i;
infile >>j;
tempGrid = new int[i][j];
}

给我一​​个错误:

error C2540: non-constant expression as array bound
error C2440: '=' : cannot convert from 'int (*)[1]' to 'int *'

如何使这个二维数组动态化?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com