array in c++

January 8, 2011 at 00:20:57
Specs: Windows XP
Why I can enter more value than the element number
#include "iostream.h"
#include "conio.h"
void main()
{
clrscr();
int arr[2];//={1,2,3,4};
cin>>arr[0];
cin>>arr[1];
cin>>arr[2];
cin>>arr[3];
cin>>arr[4];
cout<<endl<<arr[3];
getch();
}

See More: array in c++

Report •


#1
January 8, 2011 at 01:19:51
C++ doesn't do run-time checking of array indexes to ensure that they are within bounds. That is the responsibility of the programmer. But rest assured that any such misuse in a real program will cause crashes.

Report •
Related Solutions


Ask Question