[Sussex] Re: C programming help

Thomas Adam thomas at edulinux.homeunix.org
Tue Apr 26 20:14:08 UTC 2005


On Tue, Apr 26, 2005 at 11:59:28AM +0100, Captain Redbeard wrote:
> Never mind, I spent TWO HOURS yesterday stripping an incomplete
> 1,400 line program down to 100 lines to trace the source of a
> "Segmentation error", discovered what the problem was and handled
> it with <blubber>five lines of code</blubber> only to then add a
> few hundred more lines, compile it, run it and get <drumroll>a
> "Segmentation error"</drumroll><boohoo />. I'm sure I'll be back once
> I've completed another bug-hunting session, oh, happy days!

This demonstrates a severe lack of understanding.  "Hacking" it in this
way is not going to help you in the long run.

> calloc()? That's a new one. Based on the advice I was given at the
> weekend I've been using:

man calloc

>
>    CoordArray = malloc ((sizeof (struct Coords) * MAX_COORDS));
>
> Is calloc() the equivalent or does it work different in any way?

It returns allocated memory for an array of n elements.

-- Thomas Adam

--  
"One of us is a cigar stand, and one of us is a lovely blue incandescent
guillotine" -- Stephen Malkmus, "Type Slowly" from "Brighten The Corners"




More information about the Sussex mailing list