Hi. I'm working with dynamic arrays to construct a histogram. I've got an array of pointers to my histogram struct and I try to malloc() and then realloc() the array as necessary. Here's some of the code:
This would be great, except when I loop through my array, there aren't any structs. Your help is greatly appreciated.
momentBin = (void *)malloc(sizeof(hPoint *) * 10);int maxIndex =10;
//increase the size of the array
hPoint **newArr = realloc(momentBin, maxIndex*2);
else momentBin = newArr;
hPoint *temp =(hPoint *) malloc(sizeof(hPoint));
momentBin[probCounter] = temp;