1 # include <stdio.h>
2
3 void f( int * pArr, int len)
4 {
5 int i;
6
7 for(i= 0; i<len; i++)
8 printf( " %d ",*(pArr+i));
9 printf( " \n ");
10
11
12 } // 该函数实现对数组中的值的输出。
13
14 int main( void)
15 {
16 int a[ 5] = { 1, 2, 3, 4, 5};
17 int b[ 6] = {- 1, 90, 45, 35, 54, 22};
18 int c[ 100] = { 1, 31, 34, 11};
19
20 f(a, 5); // a是int * 类型
21 f(b, 6);
22 f(c, 100);
23
24 return 0;
25 }
2
3 void f( int * pArr, int len)
4 {
5 int i;
6
7 for(i= 0; i<len; i++)
8 printf( " %d ",*(pArr+i));
9 printf( " \n ");
10
11
12 } // 该函数实现对数组中的值的输出。
13
14 int main( void)
15 {
16 int a[ 5] = { 1, 2, 3, 4, 5};
17 int b[ 6] = {- 1, 90, 45, 35, 54, 22};
18 int c[ 100] = { 1, 31, 34, 11};
19
20 f(a, 5); // a是int * 类型
21 f(b, 6);
22 f(c, 100);
23
24 return 0;
25 }
/*
在Vc++6.0中显示的结果是:
====================================================
1 2 3 4 5
-1 90 45 35 54 22
1 31 34 11 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
====================================================
*/
1 # include <stdio.h>
2
3 void f( int * pArr, int len)
4 {
5 pArr[ 3] = 100; // *(pArr+3) = 100; 为什么不是*pArr[3] = 100; 呢?注意与非数组指针的区别
6 }
7
8 int main( void)
9 {
10 int a[ 6] = { 1, 2, 3, 4, 5, 6};
11 printf( " a[3] = %d\n ", a[ 3]);
12 f(a, 6);
13 printf( " a[3] = %d\n ",a[ 3]); // a[3]值已经改变
14
15 return 0;
16 }
17
18 /* 在Vc++6.0中显示的结果是:
19 =================================================
20 a[3] = 4
21 a[3] = 100
22 =================================================
2
3 void f( int * pArr, int len)
4 {
5 pArr[ 3] = 100; // *(pArr+3) = 100; 为什么不是*pArr[3] = 100; 呢?注意与非数组指针的区别
6 }
7
8 int main( void)
9 {
10 int a[ 6] = { 1, 2, 3, 4, 5, 6};
11 printf( " a[3] = %d\n ", a[ 3]);
12 f(a, 6);
13 printf( " a[3] = %d\n ",a[ 3]); // a[3]值已经改变
14
15 return 0;
16 }
17
18 /* 在Vc++6.0中显示的结果是:
19 =================================================
20 a[3] = 4
21 a[3] = 100
22 =================================================
23 */