Solved

# 2-d array

Posted on 1998-08-20

Is there any way in which I can delete an element from an array without implementing linked-list? In my program, I need to find the minimum value from the array and delete the element with minimum value. Then I repeat the step of searching for minimum value from the remaining elements and delete the element with minimum value.

If there is no way of avoiding the implementation of linked-list, please send any sample codes, information and URLs related to linked-list implementation.

I tried to use dynamic allocation to declare a 2-dimensional array but there was an error during compilation. Message was "Cannot convert void* to double*".

typedef double **matrix;

typedef double *row;

typedef double elem;

matrix get_space(int M, int N)

{ int i;

elem *p;

matrix a;

p = malloc(M*N*sizeof(elem)); //get space for all elements

a = malloc(M*sizeof(row));

--a; //offset pointer

for (i=1;i<=M;i++)

a[i]=p+((i-1)*N)-1;

return a;

}

Please advise. Thanks in advance.