错误:数组下标无效的类型'long double ** [long double]'
long double** make2darray(long int V)
{
long double **array2,i;
array2 = (long double**) malloc (V*sizeof(long double*));
for(i=0;i<V;i++)
{
array2[i] = (long double*) malloc (V*sizeof(long double));
}
return array2;
}
最佳答案
数组中的索引必须始终具有整数类型,您需要将声明更改为:
long double **array2;
size_t i;
6.5.2.1 Array subscripting (Contraints)
- One of the expressions shall have type ‘‘pointer to complete object type’’, the other expression shall have integer type, and the result has type ‘‘type’’.
std::vector
或std::array
https://stackoverflow.com/questions/24490060/