Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <malloc.h>
- void fed(int *a)
- {
- int ii;
- int b;
- for (ii=0;ii<3;ii++) {
- b=a[ii];
- printf("%i\n",b);
- }
- }
- void fed2(int **a)
- {
- int ii;
- int jj;
- for (ii=0;ii<2;ii++) {
- for (jj=0;jj<3;jj++) {
- printf("%i ",a[ii][jj]);
- }
- printf("\n");
- }
- }
- int main()
- {
- int *a;
- int **b;
- int c[2][3];
- a=(int *)malloc(3*sizeof(int));
- a[0] = 1;
- a[1] = 6;
- a[2] = 8;
- /* Allocate b */
- b=(int **)malloc(2*sizeof(int*));
- b[0]=(int *)malloc(3*sizeof(int));
- b[1]=(int *)malloc(3*sizeof(int));
- /* Init b */
- b[0][0] = 2;
- b[0][1] = -2;
- b[0][2] = 22;
- b[1][0] = 12;
- b[1][1] = -12;
- b[1][2] = 212;
- /* Init c */
- c[0][0] = 2;
- c[0][1] = -2;
- c[0][2] = 22;
- c[1][0] = 12;
- c[1][1] = -12;
- c[1][2] = -12;
- fed(a);
- fed2(b);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement