Wrong use of parameters:
while(fread(t, sizeof(char), sizeof(*t), f))
Should be
while(fread(t, sizeof(*t), 1, f))
The first returns values0 ... sizeof(*t)
.. The second returns 0 ... 1
. So to prevent a partially filled structure, use the 2nd form.
while(fread(t, sizeof(*t), 1, f)) {
if (t->apagado == '\0') {
print_registry(t); //
}
}
Of course, make certain f
and t
are not NULL
.