我正在编写一个二维数组程序,但在打印它时遇到问题,我不确定我现在是否正在正确传递二维数组,因为它崩溃而不是运行。任何意见将是有益的
void initialize(int* one, int** two);
void replace(int* arr,int rows, int cols,int value);
void fill(int* arr, int rows, int cols);
void print(int** arr, int rows, int cols);
ofstream outfile;
ifstream infile;
int arrayOne[100][100];
int arrayTwo[100][100];
int main(){
int rows,cols=0;
cout << "Please input how many rows you would like in the array: ";
cin >> rows;
cout << "Please input how many columns you would like in the array: ";
cin >> cols;
fill(arrayOne[100][100],rows,cols);
//print(arrayOne[100][100],rows,cols);
system("pause");
return 0;
}
void initialize(int* one, int* two){
for(int i=0;i<100;i++){
for(int j=0;j<100;j++){
arrayOne[i][j]=0;
arrayTwo[i][j]=0;
}
}
}
void replace(int* arr,int rows,int cols,int value){
arr[rows][cols]=value;
}
void fill(int* arr, int rows, int cols){
int i=0;
for(int r=0; r < rows; r++){
for(int c=0; c < cols; c++){
replace(arr,r,c,i++);
}
}
}
void print(int** arr, int r, int c){
for(int i=0;i<r;i++){
for(int j=0;j<c;j++){
cout << arr[i][j] << " ";
}
cout << endl;
}
}