0
I’m making a code that reads a file with records of fixed size (storing in struct
hist
), and inserts them into another formatting file so that they have variable size.
To indicate that the struct
has already been inserted, I am writing *
at the beginning of the record in the insertion file.
fread(&hist, sizeof(hist), 1, insereCopia); // faz a leitura de insereCopia
while(hist.ID_aluno[0] == '*'){ // verifica qual o próximo registro a ser inserido
fread(&hist, sizeof(hist), 1, insereCopia);
cont++;
}
fseek(insereCopia, cont * sizeof(hist), SEEK_SET); // volta ao início do reg para definir o seu tamanho e indicar que ele já foi inserido
fwrite("*", sizeof(char), 1, insereCopia);
But instead of fwrite
write only the character *
it is always inserting the first record together in the insertion file. Any suggestions?
See: https://answall.com/help/minimal-reproducible-example here in my test the writing worked as expected.
– anonimo