Unexpected result.

Bengt Richter bokr at oz.net
Thu Sep 23 17:09:26 EDT 2004


On Thu, 23 Sep 2004 14:18:01 -0500, "Larry Bates" <lbates at swamisoft.com> wrote:

>Actually the result is exactly as expected.
>Programming 101 teaches us not to reuse
>loop variables in nested loops.
>

[14:07] C:\pywk\clp>type p101.cpp
#include <cstdio>
void main(){
    char abc[]="abc";
    for(int i=0;i<3;++i){
        printf("%c ", abc[i]);
        for(int i=0;i<3;++i) printf("%d ", i);
    }
}


[14:07] C:\pywk\clp>cl p101.cpp
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8168 for 80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

p101.cpp
Microsoft (R) Incremental Linker Version 6.00.8168
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

/out:p101.exe
p101.obj

[14:07] C:\pywk\clp>p101
a 0 1 2 b 0 1 2 c 0 1 2

;-)

Regards,
Bengt Richter



More information about the Python-list mailing list