T
Tao Li
#include <stdio.h>
2
3 int mat[10][20];
4
5
6 void func(float **p){
7 int i,j;
8
9 for(i=0; i<10; i++)
10 for(j=0; j<20; j++)
11 printf("%d\n", p[j]);
12
13 }
14
15
16 int main()
17 {
18 int mat[10][20];
19 int i,j;
20
21 for(i=0; i<10; i++)
22 for(j=0; j<20; j++)
23 mat[10][20] = i + j;
24
25 func(mat);
26 return 0;
27 }
28
29
The program compiled fine, but give Segmentation fault error. I think
the reason is double pointer **P in FUNC can't access the content of
two dimentional array MAT.
How can I fix it. Thank you very much
2
3 int mat[10][20];
4
5
6 void func(float **p){
7 int i,j;
8
9 for(i=0; i<10; i++)
10 for(j=0; j<20; j++)
11 printf("%d\n", p[j]);
12
13 }
14
15
16 int main()
17 {
18 int mat[10][20];
19 int i,j;
20
21 for(i=0; i<10; i++)
22 for(j=0; j<20; j++)
23 mat[10][20] = i + j;
24
25 func(mat);
26 return 0;
27 }
28
29
The program compiled fine, but give Segmentation fault error. I think
the reason is double pointer **P in FUNC can't access the content of
two dimentional array MAT.
How can I fix it. Thank you very much