I\'d like to save a struct in a file. I\'d like to realize a function which makes this work. I tried this code but it didn\'t work.
struct utilisateur //
Try this, and then if that's not doing what you want, try explaining how it differs from what you want.
void crea_fich(struct utilisateur *Tutilis)
{
FILE *f;
size_t nwritten;
f = fopen("futilis.dat","wb");
if (f == NULL)
{
fprintf(stderr, "Cannot open file for writing.\n");
exit(1);
}
nwritten = fwrite(Tutilis, sizeof Tutilis[0], 1, f);
fclose(f);
if (nwritten < 1)
{
fprintf(stderr, "Writing to file failed.\n");
exit(1);
}
}