Hi, I am attempting to create a dynamic array using realloc in 2 dimensions.
Currently i have managed to get it to work using realloc to dynamically resize the amount of rows but when I attempt to use realloc to dynamically resize the amount of columns per row I keep getting errors. I am currently therefore using malloc() to set the amount of columns per row.
I think that there is either something wrong in my code, or it is not possible. Below is a rough example of what I am trying to do, could someone please let me know if it is possible to use realloc to set the amount of columns per row and what would the code look like?
unsigned int ** ProtocolReceiveBuffer; int rows = 2; int cols0 = 1; int cols1 = 1500; ProtocolReceiveBuffer = realloc(ProtocolReceiveBuffer, (rows)*sizeof(unsigned int*)); ProtocolReceiveBuffer = malloc((cols0)*sizeof(unsigned int)); ProtocolReceiveBuffer = malloc((cols1)*sizeof(unsigned int));