C, reading from file into structure

fscanf(reads,"%d %d %d %d %lf", n->id, n->sign, n->year, n->month, n->amount);

The scanf family of functions expect addresses. Change the fscanf line to:

fscanf(reads,"%d %d %d %d %lf", &n->id, &n->sign, &n->year,
    &n->month, &n->amount);

Side note, this is a seriously misleading line:

else { while(!feof(reads)) {

Leave a Comment