Mail Archives: djgpp/2000/03/25/22:26:52
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 -