title: read 2 bytes in hexadecimal base and convert into decimal using C language fscanf
body: <p>Well as said Im using C language and fscanf for this task but it seems to make the program crash each time then its surely that I did something wrong here, I havent dealed a lot with this type of input read so even after reading several topics here I still cant find the right way, I have this array to read the 2 bytes</p>
  
  <pre><code>char p[2]; 
  </code></pre>
  
  <p>and this line to read them, of course fopen was called earlier with file pointer fp, I used "rb" as read mode but tried other options too when I noticed this was crashing, Im just saving space and focusing in the trouble itself.</p>
  
  <pre><code>fscanf(fp,"%x%x",p[0],p[1]);
  </code></pre>
  
  <p>later to convert into decimal I have this line (if its not the EOF that we reached)</p>
  
  <pre><code>v = strtol(p, 0, 10);
  </code></pre>
  
  <p>Well v is mere integer to store the final value we are seeking. But the program keeps crashing when scanf is called or I think thats the case, Im not compiling to console so its a pitty that I cant output what has been done and what hasnt but in debugger it seems like crashing there</p>
  
  <p>Well I hope you can help me out in this, Im a bit lost regarding this type of read/conversion any clue will help me greatly, thanks =).</p>
  
  <p>PS forgot to add that this is not homework, a friend want to make some file conversion for a game and this code will manipulate the files needed alone, so while I could be using any language or environment for this, I always feel better in C language</p>