using typedef struct and pasisng pointers to functions
I am haivng problms with passing my values through functions. Can someone help find my problem or provide a solution.
Here is my code:
Code:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
void test(int**);
void test2(int**);
typedef struct
{
int **x;
}PRACTICE;
int main()
{
int i;
int j;
i = 0;
j = 0;
PRACTICE y;
test(y.x);
test2(y.x);
for(i = 0;i < 5; i++)
for(j = 0; j < 5;j++)
printf("%d\n", *(*(y.x + i) + j));
return 0;
}
void test(int**u)
{
int i;
i = 0;
u = (int**) calloc(5,sizeof(int*));
for(i = 0; i < 5; i++)
*(u + i) = (int*)calloc(5,sizeof(int));
}
void test2(int **u)
{
int i;
int j;
i = 0;
j = 0;
for(i = 0; i < 5; i++)
{
for(j =0; j < 5; j++)
{
*(*(u + i) + j) = i + j;
// printf("%d\n", *(*(u + i) + j));
}
}
}
Thank you