|
-
March 27th, 2011, 05:21 PM
#1
Pointers to array
I have a doubt regarding pointers to array. the following program gives a compilation error if while declaring the pointer i give 'int (* ptr)[3] = arr;' instead of '=&arr'. Why is it so? I am using MS visual studio for compiling the program.
#include<iostream>
using namespace std;
int arr[3] = {1,2,3};
int main()
{
int (* ptr)[3] = &arr;
cout<<"The value of arrays "<<arr[0] <<" "<<arr[1] <<" ";
getchar();
return 0;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|