home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / sys / amiga / programm / 15738 < prev    next >
Encoding:
Text File  |  1992-11-12  |  1021 b   |  39 lines

  1. Path: sparky!uunet!portal!cup.portal.com!Tony-Preston
  2. From: Tony-Preston@cup.portal.com (ANTHONY FRANCIS PRESTON)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: What is wrong with this very simple c program?
  5. Message-ID: <69359@cup.portal.com>
  6. Date: Thu, 12 Nov 92 08:16:58 PST
  7. Organization: The Portal System (TM)
  8. References:  <1992Nov10.184406.25907@sol.UVic.CA>
  9. Lines: 28
  10.  
  11. |
  12. |#include <stdio.h>
  13. |
  14. |main()
  15. |{
  16. |   int zoop[1000];
  17.                ^____This defines elements 0 to 999
  18. |      int counter;
  19. |     
  20. |        printf ("started....");
  21. |           for (counter = 0; counter < 5000; counter += 5) {
  22. |             zoop[counter] = counter;
  23.        Your counter "counter" goes beyond the end of the array
  24.        and your are trashing memory with zoop[counter], I suggest
  25.        your do:
  26.     for(counter=0; counter<1000;counter++)
  27.        {
  28.        zoop[counter] = counter*5;
  29.        };
  30.        to get the same result.
  31. |            }
  32. |               printf("done....");
  33. |               }
  34. |
  35. |
  36. |               Well... I hope somebody can see my mistake....
  37. |
  38. |               -Aaron  
  39.