fwrite() not working to write integer in binary file

后端 未结 4 970
暖寄归人
暖寄归人 2021-01-16 23:25

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          


        
4条回答
  •  暖寄归人
    2021-01-17 00:02

    You must pass the address of L->YEAR to fwrite

    fwrite(L->YEAR, sizeof(int), 1, arq);
    
    fwrite(&(L->YEAR), sizeof(int), 1, arq);
    

提交回复
热议问题