home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / sys / amiga / programm / 15662 < prev    next >
Encoding:
Text File  |  1992-11-11  |  1.5 KB  |  60 lines

  1. Path: sparky!uunet!vtserf!csugrad!jaker
  2. From: jaker@csugrad.cs.vt.edu (Jake Rose)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: What is wrong with this very simple c program?
  5. Message-ID: <BxJ92o.JBM@csugrad.cs.vt.edu>
  6. Date: 11 Nov 92 03:44:48 GMT
  7. References: <1992Nov10.184406.25907@sol.UVic.CA>
  8. Organization: Virginia Tech Computer Science Dept, Blacksburg, VA
  9. Lines: 49
  10.  
  11. aramsey@ugly.UVic.CA (Aaron  Ramsey) writes:
  12.  
  13. [Deletia]
  14.  
  15. >and normal 000 code, but it makes no difference....  Does anybody have
  16. >a clue? I've only been programming in C for a week or two, and I can't
  17. >spot any obvious problems... 8-(
  18.  
  19. >Here is the code.
  20.  
  21. >#include <stdio.h>
  22.  
  23. >main()
  24. >{
  25. >   int zoop[1000];
  26. >      int counter;
  27. >     
  28. >        printf ("started....");
  29. >           for (counter = 0; counter < 5000; counter += 5) {
  30. >             zoop[counter] = counter;
  31. >            }
  32. >               printf("done....");
  33. >               }
  34.  
  35. It would probably run fine if your upper limit were set to *1000* instead of
  36. 5000, which is not in the 0 to 999 range of the "zoop" array.  You may want
  37. to adopt a formatting scheme similar to the following corrected code, as
  38. well - it helps a lot to be able to see the structure of the code.  Of course,
  39. it's not really clear what you're trying to accomplish here, so this may not
  40. do what you want...
  41.  
  42. main()
  43.   {
  44.   int zoop[1000];
  45.   int counter;
  46.  
  47.   printf ("started....");
  48.  
  49.   for (counter = 0; counter < 1000; counter += 5)
  50.     zoop[counter] = counter;
  51.  
  52.   printf("done....");
  53.   }
  54.  
  55. >               -Aaron  
  56. -- 
  57.  
  58. Wulf                    |"Hackers do it bit by bit -
  59. jaker@csugrad.cs.vt.edu | programmers do it top-down!"
  60.