Witam.
Mam problem z przekazaniem adresów struktur do funkcji tak aby zamieniała ona oryginalne adresy a nie kopie.
#include <stdio.h>
#include <stdlib.h>
typedef struct
{
int **board;
int n;
int m;
} *mat_t;
mat_t mat_alloc( int a , int b)
{
mat_t mat=malloc(sizeof *mat);
int i;
mat->n=a;
mat->m=b;
mat->board=(int**)malloc( mat->n * sizeof(int*));
for(i=0;i<mat->n;i++)
mat->board[i]=(int*)calloc(mat->m , sizeof(int));
return mat;
}
void mat_swap( mat_t mat1 , mat_t mat2)
{
mat_t tmp=mat1;
mat1=mat2;
mat2=tmp;
}
int main()
{
mat_t x=mat_alloc(5,5);
mat_t y=mat_alloc(6,6);
mat_swap(x,y);
printf("%d %d\n" , x->n , x->m);
printf("%d %d\n" , y->n , y->m);
return 0;
}
Pozdrawiam