[prog] Segmentation fault :-(
ganesh at rapidtech.bc.ca
Mon Sep 23 23:44:39 EST 2002
On Mon, 2002-09-23 at 23:31, Sujita Purushothaman wrote:
> Jacinta Richardson wrote:
> > > I'm trying to debug a C++ program (not written by me).
> > > This program gives a segmentation fault at the line :
> > > temp = BaseSocket::Receive(unsigned char *a,int b, int c);
> > It's been about 3 years since I've really touched C or C++ but try
> > changing this to:
> > temp = BaseSocket::Receive(a, b, c);
> That's actually how the line is, I added the types so people would
> know what type a,b & c are. Dumb me. Didn't see that it would make
> no sense to a person reading :-(
Playing with char * can get real dirty. Is 'a' dynamically allocated ??
The documentation for BaseSocket::Receive(..) should throw some light
onto how it expects the arguments. Since you have the source, it must be
For all you know, you might be passing a NULL pointer to the first
argument, by way of 'a'.
> > or
> > temp = BASESocket::Receive(&a, b, c);
> > whichever is correct for the type of a.
> > As far as I remember, passing type casts into a function was always a
> > surefire way to end up with headaches.
> > Oh, and hi everyone, I'm a Perl programmer by trade. ;)
> I am going to start learning Perl in a few weeks,I think I'll be having
> free time then. Why Perl? Dunno, everyone seems to know Perl, and I
> don't. :-) Besides, I always like learning new languages, computer
> or otherwise :-)
> Programming mailing list
> Programming at linuxchix.org
More information about the Programming