Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Out of range index

Here we create an array but then try to access values that are beyond the highest index.

The compilation works, but then the code crashes.

#include<stdio.h>

int main() { int count[2]; int i;

count[0] = 0;
count[1] = 0;
count[2] = 0;
count[3] = 0;

return 0;

}

*** stack smashing detected ***: terminated
Aborted (core dumped)