title: Zero padding: How to remove zeroes from the end of file?
body: <p>I need to realize this method (<a href="https://en.wikipedia.org/wiki/Padding_%28cryptography%29#PKCS7" rel="nofollow">https://en.wikipedia.org/wiki/Padding_%28cryptography%29#PKCS7</a>) using C, which don't have convenient function to do that.</p>
  
  <p>I have added this way</p>
  
  <pre><code>int main()
  {
      FILE *file=fopen("1.xlsx", "a"); 
  
     file_add(16,file);
     fclose(file);
  }
  void file_add(int SizeOfBlock, FILE *file )
  {
      fseek(file, 0, SEEK_END);
      int size = ftell(file); // file size in bytes
      fseek(file, 0, SEEK_SET);
  
      int diff = size%SizeOfBlock;
  
      char arr[16] = "0000000000000000"; //16 zeroes
      fwrite(arr, SizeOfBlock-diff, 1 , file); // here I added to end of file missing 0 to make size of file  be dividing to SizeOfBlock
  
  }
  
  
  void file_remove (int SizeOfBlock, FILE *file)
  {
    // by this function I need to delete these zeroes
    // max amount of zeroes is limited by SizeOfBlock
  }
  </code></pre>
  
  <p>How can I do that? <code>SizeOfBlock</code> can be only 8 or 16</p>