VC6 Compiler ignores Array indexing?

Discussion in 'MCSD' started by Ultraman Aries, Jun 4, 2004.

  1. Hi, I'm a newbie VC6 user. I declare an array that holds
    5 elements and when I try to put an error for debugging
    nothing happens. I will be grateful for your effort. ;-)
    ////Heres d code

    int array[5];

    for( int i = 0; i < 6; i++ )
    array = i;

    cout<< array[3] //output: 3 OK!
    << endl
    << array[6]; //output: 6 should be an error!
     
    Ultraman Aries, Jun 4, 2004
    #1
    1. Advertising

  2. Nope, won't get a compiler error, however you should have had an
    warning displayed in the output window after running in debug mode,
    warning of a stack corruption (or like off).

    So what does this mean? It means C++ is not for children, and by being
    so, generates smaller, quicker code than would be the case if it had
    to perform bounds checking etc.

    On Fri, 4 Jun 2004 13:47:10 -0700, "Ultraman Aries"
    <> wrote:

    > Hi, I'm a newbie VC6 user. I declare an array that holds
    >5 elements and when I try to put an error for debugging
    >nothing happens. I will be grateful for your effort. ;-)
    >////Heres d code
    >
    >int array[5];
    >
    > for( int i = 0; i < 6; i++ )
    > array = i;
    >
    > cout<< array[3] //output: 3 OK!
    > << endl
    > << array[6]; //output: 6 should be an error!
    >



    Kline Sphere (Chalk) MCNGP #3
     
    The Poster Formerly Known as Kline Sphere, Jun 4, 2004
    #2
    1. Advertising

  3. If you think that is screwy, try this (switch name and index)

    int array[5]

    for( int i = 0; i < 5; i++ )
    array = i;

    for( int i = 0; i < 5; i++ )
    cout << i[array] << endl;

    ----- Ultraman Aries wrote: ----

    Hi, I'm a newbie VC6 user. I declare an array that holds
    5 elements and when I try to put an error for debugging
    nothing happens. I will be grateful for your effort. ;-
    ////Heres d cod

    int array[5]

    for( int i = 0; i < 6; i++ )
    array = i;

    cout<< array[3] //output: 3 OK
    << end
    << array[6]; //output: 6 should be an error
     
    =?Utf-8?B?SSBMb3ZlIEMrKw==?=, Jun 5, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lura Johnson [MSFT]

    Re: Is it possible to combine two core exams (.Net & VC6) to get MCSD?

    Lura Johnson [MSFT], Aug 29, 2003, in forum: Microsoft Certification
    Replies:
    0
    Views:
    832
    Lura Johnson [MSFT]
    Aug 29, 2003
  2. Gihan
    Replies:
    1
    Views:
    1,005
    Somchai U.
    Jul 31, 2003
  3. ricardodefaria
    Replies:
    6
    Views:
    1,507
    thanatoid
    Aug 5, 2007
  4. amrutha0303
    Replies:
    0
    Views:
    990
    amrutha0303
    Aug 3, 2010
  5. amrutha0303
    Replies:
    0
    Views:
    2,143
    amrutha0303
    Aug 3, 2010
Loading...

Share This Page