The name of the array is interpreted ad the address of the first element of an array,whereas applying the address operator yields the address of the whole array.ios
#include<iostream> using namespace std; int main(void) { short tell[10]; //tell a array of 20 bytes cout<<sizeof(tell)<<endl; // the result of output is 20 cout<<tell<<endl; //displays &tell[0] cout<<&tell<<endl; //displays address of whole array return 0; }
Numberically,these two addresses are the same,but conceptually &tell[0],and hence tell,is the address of a 2-byte block of memory,whereas &tell is the address of a 20-byte block of memory.
So the expression tell+1 adds 2 to the address value,whereas &tell+1 adds 20 to the address value.
tell is type pointer-to-short,or short ,and &tell is type pointer-to-array of 20-shorts or short ()[20].express
short (*pas)[20] = &tell; //pas pointer to array of 20 shorts
If you omit the parentheses,precedence rules would first associate [20] with pas,making pas an array of 20 pointers-to-short,so the parentheses are necessary.Next,if you wish to describe the type of a variable,you can use the declaration of that variable ad a guide and remove the variable name.Thus,the type of pas is short (*)[20].Also note that because pas is that set to &tell,*pas is equivalent to tell,so (*pas)[0] would be the first element of the tell array.app