我正在尝试以下代码用于多维数组.它给出SEG错误我不知道这是什么问题.
static void read(double **arr){
//REQ arr to be pointing to array[5][4]
//EFF prompt the use to input the data
//Mod array pointer by **arr
int i(0) , j(0);
double tmp ;
for(i=0 ; i<4 ; i++){
for(j=0 ; j<5 ; j++) {
cout <<"Please enter Data#"<< (j+1) << " File#" << (i+1) <<" "<<flush;
cin >> tmp ;
arr[j][i] = tmp ;
}
}
return ;
}
int main(){
double arr[5][4] ;
read(reinterpret_cast<double**>(arr) ) ;
}
Run Code Online (Sandbox Code Playgroud)
我在这做错了什么?