hi,
int arr[2][2][2]={1,2,3,4,5,6,7,8}:
int *p,*q;
q=(int*)arr;
printf("%d",*q);
my question is that how is it giving output as "1"(ofcourse, without quotes). what will change if i don't typecast arr in 3rd line of code? will anyone please explain.Is it giving o/p "1" ,just because of that typecast ?
my thinking: as arr can be viewed as the pointer to a array of pointers. so giving just *arr or q=arr will not give the value of the first element of array. right ? we must do **q in that case for printing first value of array. I think we are getting "1" here just because of some reason(which i want to know from somebody here) of that typecast in 3rd line. make me correct in my thinking if i am wrong.
thanks. any help will be thankful.