This question already has an answer here:
#include<bits/stdc++.h>
using namespace std;
int main() {
int a[5];
for(int i=0;i<=5;i++) {
cin >> a[i];
}
for(int i=0;i<=5;i++) {
cout << a[i];
}
}
The array size is 5 and it is able to scan 6 elements in it. Stack smashing error or segmentation fault should come, but the compiler simply accepts the 6 elements and displays them properly too. What is it that I'm missing?
Aucun commentaire:
Enregistrer un commentaire