help fix error

0 ishwiin doe · September 16, 2015
i believe the problem is with the double array help fix.
i would like to know how to create a multidimensional dynamic array where the user enters the value for both rows and columns.
all suggestions are welcome.

Post a Reply


Oldest  Newest  Rating
+2 Alan Masimba Walker · September 17, 2015
//Create a double pointer of type double
double** coursework = nullptr;

//Initialise the size of the first dimension
coursework = new double*[s];
//For each element in the first dimension create an array of the 2nd dimension size
for(int i = 0; i < s; ++i)
coursework[i] = new double[cw]
//Delete all the 2nd dimensions
for(int i = 0; i < s; ++i)
delete[] coursework[i];
delete[] coursework;//delete the first dimension

That should do it
0 Casper Hollemans · September 16, 2015
well, I'm not very skilled in C# but the way t is in java goes like this:

String[][] arrayName = new String[put here the lenght of the 1st array][put here the lenght of the 2ndarray]; //it has to be a int/int var.

// for example
String[][] arrayName = new String[4][5];
//now you want to give the array some value's
arrayName[0][0] = "value";
arrayName[0][1] = "value";
arrayName[0][2] = "value";
arrayName[0][3] = "value";

arrayName[1][0] = "value";
arrayName[1][1] = "value";
arrayName[1][2] = "value";
arrayName[1][3] = "value";
arrayName[1][4] = "value";

hope it helps :)

0 Jon Z. · September 16, 2015
double coursework[s][cw];
  • 1



Used in many types of software including music players, video games, and many large scale applications.

Bucky Roberts Administrator