Buongiorno a tutti.

Sto cercando di imparare l'uso delle funzioni, in un constesto in cui restituiscono una struct, ma non tutto mi e' chiaro. Vorrei domandare aiuto nel capire che cosa no va nel seguente codice.

Grazie mille per l'aiuto.
Pagnottazzo



#include <stdio.h>

typedef struct m
{
int f1;
int f2;
} tp;

main()
{



tp a;
tp b;
int i;

a.f1 = 1000;
a.f2 = 233;

printf("%d %d \n", a.f1, a.f2);

b = init();
printf("%d %d \n", b.f1, b.f2);


scanf("%d \n", &i);
}



struct m init()
{
tp M;
int a = 20;
int b = 24;
M.f1 = a;
M.f2 = b;
return(M);


// int w = 3800;
// return(w);
}