www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/03/25/22:26:52

From: Damian Yerrick <Bullcr_pd_yerrick AT hotmail DOT comRemoveBullcr_p>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Help Please
Organization: Pin Eight Software http://pineight.8m.com/
Message-ID: <jclqds0fhmlduog9iqij4jv51jinpbem45@4ax.com>
References: <20000325133610 DOT 00647 DOT 00003156 AT ng-cl1 DOT aol DOT com>
X-Newsreader: Forte Agent 1.7/32.534
MIME-Version: 1.0
Lines: 72
X-Trace: +Sdx8aIcD0vJKGU636l4QKPWRhWs+KvG66oAijBC5mW+67U4oO4BVwFnFh93WaWifO/R0lEeqXFN!MXpoocqHNjk0FCijVMUa6l2mhl+h/ZkmqfNzknzGuhjkoXX+bGLueDjAOi/M4yqsRnz26Use2xp+!jXmzaP4=
X-Complaints-To: abuse AT gte DOT net
X-Abuse-Info: Please be sure to forward a copy of ALL headers
X-Abuse-Info: Otherwise we will be unable to process your complaint properly
NNTP-Posting-Date: Sun, 26 Mar 2000 00:19:24 GMT
Distribution: world
Date: Sun, 26 Mar 2000 00:19:25 GMT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

On 25 Mar 2000 18:36:10 GMT, ripter01 AT aol DOT com (Ripter01) wrote:

>I have this strange (strange to me) problem with one of my C programs
>the frist time I run it It works just as I want it to, but anytime after that
>it prints a bunch of junk on the screen like:
>
>Exiting to due to signal SIGSEGV
>General Production Fault at eip=00002ff3
>
>and then a bunch of stuff that looks like Asm resters and stuff

Try running this after it crashes:
C:\MYPROJ>symify foo.exe
This should fill in the traceback EIPs with information that should
help you find the problem.

>If I reboot, then I can run the program once without this happaning
>but then it happans again, i don't get it, Please help,

You're probably using an uninitialized variable.

> Here is my code
>
>/* Pad.c */
>
>#include <stdio.h>
>#include <string.h>
>
>main()
>{
> char Text[20][81], CharTemp;
            ^^ array goes from 0 to 19
> int Count,Counter,Temp, i;
>
> for( i = 0; i <=20; i++)
                 ^^^ writing to index 20
>  strcpy(Text[i], "");
>
> puts("This will \"pad\" your lines");
> puts("Type quit on a newline to exit");
             ^^^^ nonportable; use the standard period on a blank line
>
> do
> {
>  Count++;
>  printf(">");
>  gets(Text[Count]);
> } while( strcmp("quit",Text[Count]) != 0 );
                   ^^^^ change this to
  } while( strcmp(".",Text[Count]) != 0 );
An international compatible interface is generally better.
Plus, a naked Enter-period-Enter is easier to type than 'quit'.

> for( Counter = 0; Counter <= Count; Counter++ )
>  if( strlen(Text[Counter]) < 70)
>    for( Temp = strlen( Text[Counter] ); Temp <= 70; Temp++ )
>     strcat(Text[Counter],".");
>
> for( Counter = 0; Counter <= 20; Counter++ )
                             ^^^^ still accessing one
                          beyond the end of the array
>  printf("\n%s",Text[Counter]);
>}


-- 
Damian Yerrick
"I refuse to listen to those who refuse to listen to reason."
See the whole sig: http://www.rose-hulman.edu/~yerricde/sig.html

This is McAfee VirusScan. Add these two lines to your signature to
prevent the spread of signature viruses.  http://www.mcafee.com/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019