Date: Wed, 18 Mar 1998 21:55:13 -0800 (PST) Message-Id: <199803190555.VAA19201@adit.ap.net> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" To: rpinnell AT characato DOT ucsm DOT edu DOT pe, djgpp AT delorie DOT com From: Nate Eldredge Subject: Re: Pointers and DJGPP Content-Transfer-Encoding: 8bit Precedence: bulk At 04:42 3/18/1998 -0500, rpinnell AT characato DOT ucsm DOT edu DOT pe wrote: >Hi I have been trying to teach myself C for the last few months or so >and have been using DJGPP. I seem to be having a lot of problems >whenever I use pointers with DJGPP. Take the following example a simple >strcat. > >#include > >void mstrcat(char *s,char *t); > >int main() >{ >char ms1[]="Hello"; >char ms2[]=" World"; >mstrcat(ms1,ms2); You have not left any space in `ms1' to add the characters from `ms2'. This is a bug in your code. [snipped] >The program compiles fine and does what I want it to when it runs but >exits with the following error message. >Exiting due to signal SIGSEGV [snipped] >Which is all Greek to me! SIGSEGV = SIGnal SEGmentation Violation. Basically, it means your program has accessed memory in an illegal way. In this case, you have written past the end of an array. >It isnīt just this simple program that I have >problems with I seem to get similar error messages whenever I pass >pointers to a function. The same things work ok if I just use arrays >rather than pointers. These, too, are with 99.9% certainty bugs in your code. > Any advice would be aprreciated. My apologies if >this is the wrong place to ask this question but it seems to me it is >more a DGJPP/DOS question that a general C one. It isn't. Many system will report illegal operations like this. These are general C questions and should be asked on a comp.lang.c newsgroup. Nate Eldredge eldredge AT ap DOT net