www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/04/04/06:30:29

From: DBI <DBI AT ficsgrp DOT com>
To: "'djgpp AT delorie DOT com'" <djgpp AT delorie DOT com>
Subject: Re:Why doesn't this code work?
Date: Thu, 04 Apr 96 13:20:00 PST
Message-ID: <31643D6F@macduff.ficsgrp.com>
Encoding: 28 TEXT, 39 UUENCODE

Dave Calvin said :

>Anyway, here's the code:
>
>#include <iostream.h>
>
>void main(void)
>{
>        int array1[50][50];
>        int array2[2];
>        int i,j;
>
>        for(i=0; i<50; i++)
>                for(j=0; j<50; j++)
>                        array1[i][j] = 0;
>
>        array2[0] = 1;
>        array2[1] = 2;
>        cout << array2[(array1[i][j])] << endl;
>}

after the for(..) loop i and j have value 50 and array1 has range   
[0-49][0-49]. So you're accessing memory outside of array1 ...

Dominique Biesmans
DBI AT ficsgrp DOT com
Dominique DOT Biesmans AT ping DOT be  

The following binary file has been uuencoded to ensure successful
transmission.  Use UUDECODE to extract.

begin 600 WINMAIL.DAT
M>)\^(BL+`0:0"``$```````!``$``0>0!@`(````Y`0```````#H``$(@`<`
M&````$E032Y-:6-R;W-O9G0 AT 36%I;"Y.;W1E`#$(`0V`!``"`````@`"``$$
M@`$`'P```%)E.E=H>2!D;V5S;B=T('1H:7,@8V]D92!W;W)K/P"R"@$%@`,`
M#@```,P'!``$``T`%``I``0`*0$!((`#``X```#,!P0`!``-`!``)P`$`",!
M`0F``0`A````0SDV030Q1C4Q0CA%0T8Q,3 AT Q-$8P,#@P0S AT Q1D0X,$(`.0<!
M!)`&`&@!```!````#0````,``#`"````"P`/#@`````"`?\/`0```$H`````
M`````&"49&!!N`$(`"LKBBD``&U$B`!D`!H`.``2````%``G9&IG<'!`9&5L
M;W)I92YC;VTG`&1J9W!P0&1E;&]R:64N8V]M````'@`",`$````%````4TU4
M4``````>``,P`0```!(```!D:F=P<$!D96QO<FEE+F-O;0````,`%0P!````
M`@'Y#P$```!!`````````($K'Z2^HQ`9G6X`W0$/5`(```$`9&IG<'!`9&5L
M;W)I92YC;VT`4TU44`!D:F=P<$!D96QO<FEE+F-O;0`````#`/X/!@```!X`
M`3`!````%````"=D:F=P<$!D96QO<FEE+F-O;2<``@$+,`$````7````4TU4
M4#I$2D=04$!$14Q/4DE%+D-/30```P``.0`````+`$`Z``````(!]@\!````
M!`````````+_0P$#D`8`5`,``!`````+`",```````,`)@``````"P`I````
M```#`#8``````$``.0#`%^+!&"*[`1X`<``!````'P```%)E.E=H>2!D;V5S
M;B=T('1H:7,@8V]D92!W;W)K/P```@%Q``$````6`````;LB&,'8]4%JRHX;
M$<^!3P"`R!_8"P```P`&$$"8E!`#``<05P$``!X`"!`!````90```$1!5D5#
M04Q624Y304E$.D%.65=!62Q(15)%4U1(14-/1$4Z(TE.0TQ51$4\24]35%)%
M04U(5D])1$U!24XH5D])1"E)3E1!4E)!63$U,#4P.TE.5$%24D%9,C([24Y4
M22Q*.T8``````@$)$`$````,`@``"`(``+<#``!,6D9U?"I(4_\`"@$/`A4"
MJ`7K`H,`4`+R"0(`8V@*P'-E=#(W!@`&PP*#,@/%`@!P<D)Q$>)S=&5M`H,S
M]P+D!Q,"@'T*@`C/"=D"@*<*@0VQ"V!N9P'0- AT WP!PL*%%$+\2!$879EE"!#
M!T!V"X`@<PMP&&0@.@J%"H4^06Z`>7=A>2P@:`20U&4G!"!T&_`@!:`-L-4:
M=CX:]B,+@&,*0`VP,"`\:6\3P!8086W,+F@=9QKV=F\:00#`E0N`*"!"*1KV
M7'L:]EX@(E4+@`5`"L!R&[`QT%LU,%TC<CLAWR+F&#);,B/O(L-I+&J')=<E
M[@(0<BAI/1<0S2+`/".`*5$K*R$G)(;5*&IJ*3)J*8-J*>\MGP4C!FDCH&I=
M(#T AT OQ<0)V\N6B60(Y`O AT 3$EW[4E13$O<C(R+P6@=05`U#P\)38H+LHI+W`U
M8?T)\&0"<"$W%S(*OQCU."4>80&`!)`<4RCB+BXI\B`5H&]P(L`C`#=`+!#;
M&^`9<G8'0`I0(".`.\-_(Q0\(00@(S`7P!F0,;`M+#0Y(Z`^<RX&`&\@FGD(
M8"<6$",`8V,'D)\`D!?`((`3X`6P>2`U(;,`D!Y1;V8]1CL@+AJ,ID0#<`N`
M:7$\L4((D`IS`X%S0K9"24!F2&EC<PG`<"X%H&TE0KXN0\9`<$!!+F(693 AT E
M%3$`2&`#`!`0``````,`$1``````0``',(#.W3$8(KL!0``(,(#.W3$8(KL!
2'@`]``$````$````4F4Z`&_E
`
end

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019