1 #include<iostream>
2 #include<cstring>
3 using namespace std;
4
5 void func(short arr[])
6 {
7 cout << "in func, sizeof(arr) = " << sizeof arr << endl;
8 }
9 int main()
10 {
11 short arr[10] = {0};
12 short *p = arr;
13 cout << "sizeof(arr) = " << sizeof arr << endl;
14 cout << "sizeof(p) = " << sizeof p << endl;
15 cout << "sizeof(*p) = " << sizeof *p << endl;
16 func(arr);
17
18 char *chptr1 = "abcd";
19 char *chptr2 = new char[strlen("abcd") + 1];
20 strcpy(chptr2,"abcd");
21 char *chptr3 = "abcd";
22
23 char charr1[] = "abcd";
24 char charr2[10] = {};
25 strcpy(charr2, "abcd");
26
27 cout << "address of chptr1: "<< (int *) chptr1 << endl;
28 cout << "address of chptr2: "<< (int *) chptr2 << endl;
29 cout << "address of chptr3: "<< (int *) chptr3 <<endl;
30
31 cout << "address of charr1: "<< (int *) charr1 <<endl;
32 cout << "address of charr2: "<< (int *) charr2 <<endl;
33
34 delete [] chptr2;
35 }