title: Read In Hex Values (C)
body: <p>I am currently attempting to read in Hex values from a text file.</p>
  
  <p>There can be multiple lines of Hex's and each line can be as long as needed:</p>
  
  <pre><code>  f53d6d0568c7c7ce
  
    1307a7a1c84058
  
    b41af04b24f3eb83ce
  </code></pre>
  
  <p>Currently, I put together a simple loop to read in the Hex values into an <code>unsigned char line[500]</code> with fscanf as such:</p>
  
  <pre><code>  for(i=0; i &lt; 500; i++)
    {
          if (fscanf(fp, "%02x", &amp;line[i]) != 1) break;
    }
  </code></pre>
  
  <p>At the current moment, this only reads in the first line. As well, it is definitely not the best approach to just throw in a random 500 there to read.</p>
  
  <p>I was assuming I could use <code>sscanf</code> with <code>fgets</code> or something of that nature. But I was unsure if this would be the best approach.</p>
  
  <p>If anyone could help point me in the right direction, I would greatly appreciate it.</p>