title: converting a hex string array to hex array
body: <p>I am struggling to get a string to be understood as a hexstring  during processing. I am writing a small program where I get an input ascii text as a hex string.</p>
  
  <p>That is  i read:</p>
  
  <pre><code>char *str = "313233";
  </code></pre>
  
  <p>This is actually 0x31, 0x32 and 0x33 which is actually the string "123".</p>
  
  <p>I need an unsigned char array as follows:</p>
  
  <pre><code>unsigned char val[] = {0x31, 0x32, 0x33};
  </code></pre>
  
  <p>When I tried sscanf or sprintf, they expect integer array to be the destination pointer :(</p>
  
  <p>That is, something like:</p>
  
  <pre><code>sprintf(str, "%2x", &amp;val[0]);
  </code></pre>
  
  <p>How to do this? Perhaps this is very trivial but somehow I am confused.</p>
  
  <p>Thanks.</p>