home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!gumby!destroyer!cs.ubc.ca!keats.rick.cs.ubc.ca!not-for-mail
- From: c1a192@rick.cs.ubc.ca (Oliver Erik Seiler)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: What is wrong with this very simple c program?
- Date: 10 Nov 1992 14:19:03 -0800
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Lines: 32
- Message-ID: <1dpcgnINNf88@keats.rick.cs.ubc.ca>
- References: <1992Nov10.184406.25907@sol.UVic.CA>
- NNTP-Posting-Host: keats.rick.cs.ubc.ca
-
-
- aramsey@ugly.UVic.CA (Aaron Ramsey) coded this thingy:
- >#include <stdio.h>
- >
- >main()
- >{
- > int zoop[1000];
- ^^^^
- > int counter;
- >
- > printf ("started....");
- > for (counter = 0; counter < 5000; counter += 5) {
- ^^^^
- > zoop[counter] = counter;
- > }
- > printf("done....");
- > }
-
- Well you are writing to locations past the bounds of the array. Since the
- array is local, it is on the stack. SO you are overwriting values on the
- stack (since the stack is organized backwards in memory)... ie. You are
- killing the return addresses which are placed on the stack. Therefore you guru
-
- Change the size of the array, or the bounds of the 'for' loop...
-
- -Oliver
-
- --
- \ Oliver Seiler /\ \ / / _ |||||
- \ / \ \ / / /o\__ <--- My dream car... (o o)
- \ / \ \/ /_______-O--O'_____ \^
- \_Insomniak_/ \_c1a192@rick.cs.ubc.ca_/ _| |_
-