Can someone tell my why won\'t this function work? I just can\'t get it...
void writeRegister(FILE *arq, Book *L){ //writes in actual file position
char
The signature of fwrite is
std::size_t fwrite( const void* buffer, std::size_t size, std::size_t count, std::FILE* stream );
The first argument to the function needs to be a pointer. I am surprised you didn't get compiler errors with the following lines.
fwrite(L->YEAR, sizeof(int), 1, arq);
fwrite(L->PAGES, sizeof(int), 1, arq);
fwrite(L->PRICE, sizeof(float), 1, arq);
They need to be
fwrite(&(L->YEAR), sizeof(int), 1, arq);
fwrite(&(L->PAGES), sizeof(int), 1, arq);
fwrite(&(L->PRICE), sizeof(float), 1, arq);
Also, it is a good practice to check the return values of all IO functions to make sure that they work as you expect them to.
if ( fwrite(&(L->YEAR), sizeof(int), 1, arq) != 1 )
{
// Deal with the error condition.
}