title: fwrite() not working to write integer in binary file
body: <p>Can someone tell my why won't this function work? I just can't get it...  </p>
  
  <pre><code>void writeRegister(FILE *arq, Book *L){ //writes in actual file position
    char c = '|';
    int sizeRegWrite = reglen(L); //reglen() returns the size of Book
    fwrite(&amp;sizeRegWrite, sizeof(int), 1, arq);
  
    fwrite(L-&gt;TITLE, sizeof(char), strlen(L-&gt;TITLE), arq);
    fwrite(&amp;c, sizeof(char), 1, arq); //writing delimiter
  
    fwrite(L-&gt;AUTHOR, sizeof(char), strlen(L-&gt;AUTHOR), arq);
    fwrite(&amp;c, sizeof(char), 1, arq); //writing delimiter
  
    fwrite(L-&gt;PUBLISHER, sizeof(char), strlen(L-&gt;PUBLISHER), arq);
    fwrite(&amp;c, sizeof(char), 1, arq); //writing delimiter
  
    fwrite(L-&gt;YEAR, sizeof(int), 1, arq);
    fwrite(&amp;c, sizeof(char), 1, arq); //writing delimiter
  
    fwrite(L-&gt;LANGUAGE, sizeof(char), strlen(L-&gt;LANGUAGE), arq);
    fwrite(&amp;c, sizeof(char), 1, arq); //writing delimiter
  
    fwrite(L-&gt;PAGES, sizeof(int), 1, arq);
    fwrite(&amp;c, sizeof(char), 1, arq); //writing delimiter
  
    fwrite(L-&gt;PRICE, sizeof(float), 1, arq);
    fwrite(&amp;c, sizeof(char), 1, arq); //writing delimiter
          return;
  }  
  </code></pre>
  
  <p><strong>The struct Book is declared like this:</strong>  </p>
  
  <pre><code>typedef struct {
      char *TITLE;
      char *AUTHOR;
      char *PUBLISHER;
      int YEAR;
      char *LANGUAGE;
      int PAGES;
  float PRICE;
  } Book;
  </code></pre>
  
  <p><strong>Main</strong>  </p>
  
  <pre><code>int main() {
  FILE *arq = fopen("BD_books2.bin", "rb+");
  if(arq == NULL)
      printf("Error while opening file!!!");
  
  Book L;
  readData(&amp;L); //Reads all fields from keyboard and places in Book. Working properly
  writeRegister(arq, &amp;L);
  
  system("pause");
  return 0;
  </code></pre>
  
  <p>}</p>
  
  <p>I have to use those pointers inside the struct, so I can't remove them. By the way, my problem is only with those <code>integers</code> and the <code>float</code>.  </p>
  
  <p>This fuction is only working properly if I write all the integers and floats (YEAR, PAGES and PRICE) with <code>fprintf()</code>, but I'm writing it in a binary file, and of course I want to write it in binary, so I'm trying to use fwrite().  </p>
  
  <p>Another thing is: the compiler is pointing <code>incompatible type for argument 1 of 'fwrite'</code> at this line: <code>fwrite(L-&gt;PRICE, sizeof(float), 1, arq);</code>  </p>
  
  <p>Can someone explain me what is happening? <strong>My program crashes when it tries to write in the file...</strong></p>