title: How to read 16 bytes each from a File in C using for loop
body: <p>I need to read 16 bytes each (because I need to cipher each block of 16 bytes individually) using for loop its not working. Can't figure out where am missing it :(</p>
  
  <p>my complete code</p>
  
  <pre><code>typedef unsigned char BYTE;
  FILE *fp;
  BYTE buffer[16] = {0x00}; 
  int i;
  int lastBlock;
  int main (int argc, char *argv[])
  {
      int x;
      fp = fopen(argv[1], "r");
      fseek(fp, 0, SEEK_END);
      int fileSize = ftell(fp);
      fseek(fp, 0, SEEK_SET);
      lastBlock = fileSize - 16;
      printf("FileSize %d \n", fileSize);
      printf("Lastblcok %d \n", lastBlock);
      for(x = 0;  x &lt; lastBlock;  i+16){
          fread(buffer, 1, 16, fp);
          printf("%s\n", buffer);     
      }
      return(0);
  }
  </code></pre>
  
  <p>What's my mistakes ? Last block variable is fine. It prints out rubbish. It's just a plain text file.</p>