Complete.Org: Mailing Lists: Archives: discussion: February 2000:
[aclug-L] Re: Simple C question (which shows my C ignorance)
Home

[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]
To: aclug-L@xxxxxxxxxxxx
Subject: [aclug-L] Re: Simple C question (which shows my C ignorance)
From: Larry Bottorff <mrprenzl@xxxxxxxxxx>
Date: Thu, 03 Feb 2000 06:52:30 -0600
Reply-to: aclug-L@xxxxxxxxxxxx

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



[Prev in Thread] Current Thread [Next in Thread]