dynamic-allocation

size of dynamically allocated array

Hi, Is it true that a pointer assigned to the starting address of a dynamically allocated array does not have the information of the size of the array? So we have to use another variable to store its size for later processing the array through the pointer. But when we free the dynamically allocated array, we don't specify the size, ins...

How do I allocate a 2 D array with contigious memory ? How Do I use it to access rows and columns? Give me an example.

I have created a 2 d array which reads as follows int i,j,lx,ly;// lx,ly are the row and column respectively double** a; a=(double**) malloc((lx+2)*sizeof(double)); a[0]= (double*) malloc((lx+2)*(ly+2)* sizeof(double)); assert(a[0]); for(i=1;i<lx+2;i++) { a[i]=a[i-1]+i*(ly+2); } // I...

Java Collections automatic reallocation when size is reached.

I'm not sure if I'm using the correct terms, but I am curious how it's determined how much to increase the size of a Collection in Java when it gets full? I've tried searching but I'm not really coming up with anything useful. So, if I have something like List l = new ArrayList(1); l.add("1"); l.add("2"); How does it determine how mu...

how does C know dimensions of 2d dynamic array in a function?

I saw this example when I was trying to figure out how to pass pointers to dynamically allocated 2d arrays to functions: void zeroit(int **array, int nrows, int ncolumns) { int i, j; for(i = 0; i < nrows; i++) { for(j = 0; j < ncolumns; j++) array[i][j] = 0; } } I tried it and it works, but I don't understand how. How doe...