Article View: comp.sys.apple2.gno
Article #266Re: Crash............
From: Kevin Henigan
Date: Mon, 16 Nov 1992 12:49
Date: Mon, 16 Nov 1992 12:49
45 lines
1679 bytes
1679 bytes
In article <1992Nov16.073159.14009@ils.nwu.edu> chauhan@aristotle.ils.nwu.edu (Amrit Chauhan) writes:
>
>/* prob8.c -- Programming Exercises (Chapter VI, Problem 8) */
>#include <stdio.h>
>#define MAX 7
>main()
>{
> int i, integers[MAX];
integers[7]; allocates ONLY 7 ints, that is 0 to 6!!
>
> printf("Please enter 8 integer values below:\n");
>
> for(i = 0; i <= MAX; i++)
> scanf("%d", &integers[i]);
here you read 8 values in, 0-7.
> printf("Right back at you...\n");
>
> for(i = MAX; i >= 0; i--)
> printf("%d ", integers[i]);
> printf("\n");
>}
You allocate 7 integers 0-6 and use 8, 0-7 !!!!
>Well, this one crashes...in very weird ways.
If you overwrite things that you haven't allocated, funny things will
start to happen :-)
From what you say you have overwritten the stack, so upon exit it jumps
somewhere and tries to do ....
>Amrit
>achauhan@math.macalstr.edu
--
Kevin Henigan. UUCP: {backbone}!unido!quando!henigan OR henigan@quando.uucp
Quantum GmbH Bitnet: henigan%quando@UNIDO(.bitnet)
Dortmund internet: henigan@quantum.de, or henigan@quando.quantum.de
Germany advert : PEDIGREE - the only genealogy IIGS prog with a GUI
Technical Details
Message-ID:
<1992Nov16.124910.29462@quando.quantum.de>Path:
arc1-ca.pugleaf.net!sparky!uunet!mcsun!Germany.EU.net!quando!heniganReferences:
<1992Nov16.073159.14009@ils.nwu.edu>Show Full Headers
Complete Article Headers
Newsgroups: comp.sys.apple2.gno Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!Germany.EU.net!quando!henigan From: henigan@quando.quantum.de (Kevin Henigan) Subject: Re: Crash............ Message-ID: <1992Nov16.124910.29462@quando.quantum.de> Organization: Quantum Software GmbH, Dortmund, Germany References: <1992Nov16.073159.14009@ils.nwu.edu> Date: Mon, 16 Nov 1992 12:49:10 GMT Lines: 45