Here is the structure:
typedef struct {
int nr_operations;
int *operations_idxs;
} sensor;
I try to read from a FILE elements in operations_idxs.
I get segmentation fault using this code:
S[i].operations_idxs=(int*)malloc(S[i].nr_operations*sizeof(int));
fread(&S[i].operations_idxs, sizeof(int), S[i].operations_idxs, f);
But works well with this code, reading right data:
S[i].operations_idxs=(int*)malloc(S[i].nr_operations*sizeof(int));
for( j=0; j<S[i].nr_operations; j++) {
fread(&S[i].operations_idxs[j], sizeof(int), 1, f);
}