+ 5
Please somebody explain me the output.
#include <iostream> using namespace std; int main() { int a[10]; cout<<sizeof(a[1]); cout<<sizeof(a[10]); return 0; } why it shows the size of a[10] as 4 shouldn't it give error as it is out of bound beacause the index is only from 0 to 9?
5 Antworten
+ 4
@vishnu
yes but it is giving me the output. Do give it a try on code playground.
+ 3
@Mara
i am only asking why it is showing the size of a[10] as 4,
it should be an error.
+ 3
@vishnu
do you mean like this
char a[10]
cout<<sizeof(a[10])
in this way or any other?
+ 1
a[10]
doesn't exists...
only upto 9
a[0] to a[9]