This declares a pointer and initialises it to be a null pointer:
Consequently, cur_pos needs to actually point to an int object, otherwise you cannot do this:
Code:
*cur_pos = posIniziale[a[i].column];
since you cannot dereference a null pointer. Perhaps you should just make cur_pos an int instead.
Also, this looks suspect:
Code:
int * terminiRiga = malloc(sizeof(Triple *)*NUMR);
int * posIniziale = malloc(sizeof(Triple *)*NUMC);
terminiRiga is a pointer to an int, so we would expect that it either points to a single standalone int object, or it points to some int object (typically the first) in an array of int objects, or perhaps one past the end of such an array of int objects. However, according to the malloc call, you allocate space for NUMR objects of type pointer to Triple. If this malloc call is correct, then we would expect terminiRiga to be a pointer to a pointer to Triple:
Code:
Triple **terminiRiga = malloc(sizeof(Triple*) * NUMR);
and in fact we could write:
Code:
Triple **terminiRiga = malloc(sizeof(terminiRiga[0]) * NUMR);
However, it looks like you use terminiRiga as if it were an array of int, in which case you should have written:
Code:
int *terminiRiga = malloc(sizeof(terminiRiga[0]) * NUMR);
Likewise for posIniziale.
That said, this might make no real difference because it could be the case that sizeof(Triple *) == sizeof(int), i.e., it would be good for correctness, but not necessarily change anything in the resulting compiled code.