repl.it
@m_s__santos/

using-wrong-indexes-in-array

C

C does not give a shit about you using wrong indexes in a array. Because of this, arrays in C are fast.

fork
loading
Files
  • main.c
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <stdio.h>

int main() {
  int numbers[10];
  numbers[0] = 42;
  
  printf("%d\n", numbers[0]);
  
  // Negative index.
  printf("%d\n", numbers[-1]);
  
  // Index that was not initialized.
  printf("%d\n", numbers[1]);
  
  return 0;
}