[aclug-L] Re: Simple C question (which shows my C ignorance)
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
John Reinke wrote:
> I'm not sure I follow what you are doing, but if you used malloc to declare
> the array, and want to shorten the array by one, shift everything down, and
> do a realloc reflecting the new size of the array.
I do a malloc for each member of the array (of stuctures) :
array1[count]=(mystruct*)malloc(sizeof(mystruct)) as I need it after declaring
array1[NUM] beforehand. Then I need to remove a given member of array1. I've
tried: free(array[i]); accnts[i] = NULL; but that gave a seg fault. If I
shift everything down, how do I use realloc? Somebody else suggested memcpy,
but again, I'm the rookie.
--
Larry Bottorff / mrprenzl@xxxxxxxxxx / 316.345.3387
|
|