| www.delorie.com/archives/browse.cgi | search |
| Message-ID: | <3736A098.55E268BE@softhome.net> |
| From: | Chris Mears <chris_mears AT softhome DOT net> |
| X-Mailer: | Mozilla 4.04 [en] (Win95; I) |
| MIME-Version: | 1.0 |
| Newsgroups: | comp.os.msdos.djgpp |
| Subject: | Re: ? array[n] or array[n+1] ? |
| References: | <37367f71 DOT 6271443 AT news DOT wanadoo DOT fr> |
| Lines: | 30 |
| Date: | Mon, 10 May 1999 19:02:16 +1000 |
| NNTP-Posting-Host: | 139.134.194.206 |
| X-Trace: | newsfeeds.bigpond.com 926326530 139.134.194.206 (Mon, 10 May 1999 18:55:30 EST) |
| NNTP-Posting-Date: | Mon, 10 May 1999 18:55:30 EST |
| Organization: | Telstra BigPond Internet Services (http://www.bigpond.com) |
| To: | djgpp AT delorie DOT com |
| DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
| Reply-To: | djgpp AT delorie DOT com |
Because you're overrunning the array. "int bit[63][6]" means that the
first index must be between 0 and 62 inclusive, and the second is
between 0 and 5, inclusive. I don't know why Visual C complains, but
the reason djgpp doesn't is because it trusts you. It assumes you know
what you're doing, and lets you do it uninhibited.
Chris
Gallicus wrote:
>
> Can somebody explain why
>
> int bit[63] [6];
>
> for (i=0; i<= 63; i++)
> { k=i;
> for (j=1;j<=6; j++)
> { bit[i][j] = k % 2;
> k=k / 2;
> }
> }
>
> throws a runtime error with MS Visual C++ 5.0 (because it requires
> int bit[64] [7])
>
> and DJGPP is quite satisfied with int bit[63] [6] ?
>
> TIA.
>
> Gallicus.
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |