[Sussex] Re: C programming help
Captain Redbeard
hairy.one at virgin.net
Tue Apr 26 13:55:35 UTC 2005
Ahoy there,
>Geoffrey Teale wrote:
>
>Cap'n,
>
>If I'd seen your mail I'd have waded in
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!
>Steve Dobson wrote:
>
>The numbers of ways one can screw up the use of dynamic memory use are legion.
Yeah, tell me about it!
>I don't know of any books, I learnt the hard way, just as you are now doing. I know, that doesn't help much does it.
Quite!
>It is a very good idea (practice) to all ways initialise any variables.
See my note above, that WAS the five lines of code :)
>You need to insert before this line:
>
> CoordArray = (Coords *) calloc(MAX_COORDS, sizeof(struct Coords));
calloc()? That's a new one. Based on the advice I was given at the weekend I've been using:
CoordArray = malloc ((sizeof (struct Coords) * MAX_COORDS));
Is calloc() the equivalent or does it work different in any way?
Anyway, I'm probably jumping in at the deep end a bit with this program as it uses a LOT of dynamic memory allocation and pointer to structs and functions but I'm learning fast, the painful way, so I think it's "ALMOST THERE (TM)."
Stay tuned!
Captain Redbeard.
====================================================
Being as I am, a relatively politically-aware kind
of guy, I am always ready to inform myself, as any
True Citizen should be, of what is happening in this
small world of ours, what threats there are to our
livelihood and well-being and what we must face up to
if we are to protect our freedom and civil liberties
that make this civilisation a pleasure to be a part
of. In this wise I logged on, as any True Citizen
should, to http://www.conspiracy.com/ to find out
what is really going on in this world of ours. And
what do you think I was first confronted with when
the home page came up?
www.businesslink.gov.uk/ <http://www.conspiracy.com/site/redirps.htm?p=28&ws=182&enc=1&vars=%2F37%7Eeqpurktce%7B%7Ejvvr%3C11rcigcf40iqqingu%7Bpfkecvkqp0eqo1rcigcf1kenmAuc%3Fn%28ck%3FDWaKXcj3wStsEL85mN%5Ct2iJUP47iNm%3AVFrCJCldeD6KmeGCG%5BCUE6uLiEMCXCkj%5CKvlosCTr2%5CZP2Z%7CC%7COUv2%5CZP2Z%7CC2OEv2%5CZP2Z%7CCyPNKDFoPxdpPycZLj%5B5mw%5B4%3Bv%7BCGD4iGkcJT2eFqxN4PxdpPycZLj%5B5mw%5B4%3BvN%7B22OVC5QFS7O%7CW4%5CC%28pwo%3F3%28cfwtn%3Fjvvr%3C11yyy0dwukpguunkpm0iqx0wm1%275Hve%275F222MY242474276%28enkgpv%3Fec%2Ffr%2Ffqockpcevkxgazon%28fqockpapcog%3Feqpurktce%7B0eqo%7E2%7E2%7E3%7E%7E%7E449%7E2%7E2%7E%2F3%7Ekhf4yu2mxfwi46jpze5%3Bm6qe%7E3336734968%7E3%3A88%3B72%3D3222%3A%3A6%3B%7E2%7E4%3A%7E84047403%3B40%3B>
Now I AM informed!
====================================================
More information about the Sussex
mailing list