title: Can't read the Binary file While I using fread in C
body: <p>I am having a problem with reading Binary data using fread in C.</p>
  
  <p>So here is the binary file that I need the read.</p>
  
  <p><a href="https://i.stack.imgur.com/7qfK6.png" rel="nofollow noreferrer">https://i.stack.imgur.com/7qfK6.png</a></p>
  
  <p>My problem is that file has normal text in five lines and I can't figure out how to avoid them or read them as text and when the binary part comes starting reading binary data.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>size_t num;
  FILE *fp = fopen("binaryXYZRGB.nkt", "rb");
  
  if(fp == NULL){
      printf("HATA!!!\n");
      exit(1);
  }
  
  int counter = 0;
  while(1){
  
      struct read a;
      num = fread(&amp;a, 1, sizeof(a), fp);
      printf("%d-) %f %f %f %d %d %d\n", counter, a.x, a.y, a.z, a.r, a.g, a.b);
  
      counter++;
  
      if(num &lt; 1){
          break;
      }
  }
  </code></pre>
  
  <p>and read struct:</p>
  
  <pre><code>struct read{
   float x;
   float y;
   float z;
   int r;
   int g;
   int b;  
  };
  </code></pre>
  
  <p>I probably read something like this</p>
  
  <p><a href="https://i.stack.imgur.com/ZYUbY.png" rel="nofollow noreferrer">https://i.stack.imgur.com/ZYUbY.png</a></p>
  
  <p>but I read this,</p>
  
  <p><a href="https://i.stack.imgur.com/fbaqd.png" rel="nofollow noreferrer">https://i.stack.imgur.com/fbaqd.png</a></p>
  
  <p>If someone could help me that will be great.</p>