home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!portal!cup.portal.com!Tony-Preston
- From: Tony-Preston@cup.portal.com (ANTHONY FRANCIS PRESTON)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: What is wrong with this very simple c program?
- Message-ID: <69359@cup.portal.com>
- Date: Thu, 12 Nov 92 08:16:58 PST
- Organization: The Portal System (TM)
- References: <1992Nov10.184406.25907@sol.UVic.CA>
- Lines: 28
-
- |
- |#include <stdio.h>
- |
- |main()
- |{
- | int zoop[1000];
- ^____This defines elements 0 to 999
- | int counter;
- |
- | printf ("started....");
- | for (counter = 0; counter < 5000; counter += 5) {
- | zoop[counter] = counter;
- Your counter "counter" goes beyond the end of the array
- and your are trashing memory with zoop[counter], I suggest
- your do:
- for(counter=0; counter<1000;counter++)
- {
- zoop[counter] = counter*5;
- };
- to get the same result.
- | }
- | printf("done....");
- | }
- |
- |
- | Well... I hope somebody can see my mistake....
- |
- | -Aaron
-