home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!vtserf!csugrad!jaker
- From: jaker@csugrad.cs.vt.edu (Jake Rose)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: What is wrong with this very simple c program?
- Message-ID: <BxJ92o.JBM@csugrad.cs.vt.edu>
- Date: 11 Nov 92 03:44:48 GMT
- References: <1992Nov10.184406.25907@sol.UVic.CA>
- Organization: Virginia Tech Computer Science Dept, Blacksburg, VA
- Lines: 49
-
- aramsey@ugly.UVic.CA (Aaron Ramsey) writes:
-
- [Deletia]
-
- >and normal 000 code, but it makes no difference.... Does anybody have
- >a clue? I've only been programming in C for a week or two, and I can't
- >spot any obvious problems... 8-(
-
- >Here is the code.
-
- >#include <stdio.h>
-
- >main()
- >{
- > int zoop[1000];
- > int counter;
- >
- > printf ("started....");
- > for (counter = 0; counter < 5000; counter += 5) {
- > zoop[counter] = counter;
- > }
- > printf("done....");
- > }
-
- It would probably run fine if your upper limit were set to *1000* instead of
- 5000, which is not in the 0 to 999 range of the "zoop" array. You may want
- to adopt a formatting scheme similar to the following corrected code, as
- well - it helps a lot to be able to see the structure of the code. Of course,
- it's not really clear what you're trying to accomplish here, so this may not
- do what you want...
-
- main()
- {
- int zoop[1000];
- int counter;
-
- printf ("started....");
-
- for (counter = 0; counter < 1000; counter += 5)
- zoop[counter] = counter;
-
- printf("done....");
- }
-
- > -Aaron
- --
-
- Wulf |"Hackers do it bit by bit -
- jaker@csugrad.cs.vt.edu | programmers do it top-down!"
-