title: C convert hex to decimal format
body: <p>Compiling on linux using gcc.</p>
  
  <p>I would like to convert this to hex. 10 which would be a.
  I have managed to do this will the code below.     </p>
  
  <pre><code>unsigned int index = 10;
  char index_buff[5] = {0};
  sprintf(index_buff, "0x%x", index);
  data_t.un32Index = port_buff;
  </code></pre>
  
  <p>However, the problem is that I need to assign it to a structure 
  and the element I need to assign to is an unsigned int type.</p>
  
  <p>This works however:</p>
  
  <pre><code>data_t.un32index = 0xa;
  </code></pre>
  
  <p>However, my sample code doesn't work as it thinks I am trying to convert
  from an string to a unsigned int.</p>
  
  <p>I have tried this, but this also failed</p>
  
  <pre><code>data_t.un32index = (unsigned int) *index_buff;
  </code></pre>
  
  <p>Many thanks for any advice,</p>