I am having trouble using a function.
I have two functions.
createTwoDArray: prompts user for row and column sizes, creates a new 2D array and returns it while also modifying the row and column variables passed to it.
printTwoDArray: should take in a 2d array and print everything. However, when calling this function, segmentation fault occurs immediately. Not one line of code inside the function is called even.
Thank you :)
int column, row;
char** createTwoDArray(int& column, int& row) {
int min, max, i, j;
cout << "\nPlease enter row size:";
cin >> i;
row = i;
cout << "\nPlease enter column size:";
cin >> j;
column = j;
char** dynamicArray2 = new char*[column];
for(i = 0; i < row; i++) {
dynamicArray2[i] = new char[column];
for(j = 0; j < column; j++) {
dynamicArray2[i][j] = '\0';
}
}
return dynamicArray2;
}
void printTwoDArray(char** array, int row, int column) {
//
}
//
char** array2 = new createTwoDArray(column, row)
printTwoDArray(array2, column, row); //this causes the segmentation error
//
'while pressing Enter) things break quickly in your code.