1

Consider the following code. Why does this work?

#include <iostream>
using namespace std;

int main()
{
    int i[10] = {1,2,3,4,5,6,7,8,9,10};
    int array = 4;
    cout << array[i] << endl; 
}

This compiles without warnings and errors and outputs 5.

trenki
  • 7,133
  • 7
  • 49
  • 61

0 Answers0