title: Unsuccessfully using sscanf to read in hexadecimal value
body: <p>Here is a much more short version of my code:</p>
  
  <pre><code>char token[256];
  unsigned int maskval = 0;
  
  //Token gets read in here.
  
  printf("token: %s\n", token);
  
  if (sscanf(token + 2, "%x", &amp;maskval) == 1) {
       //do stuff
  } else {
       printf("error: %d, %x\n", maskval, maskval);
  }
  </code></pre>
  
  <p>As you can see I am passing hexadecimal strings to the function, reading them into token and using sscanf() to convert the string version of the hexadecimal value into a unsigned int. The string token always begins with "0x", "0X", "Ox", or "OX". The reason for this is because the user will be unable to tell the difference between a 0 or a O when inputting the value (vi displays them the same, graphical). The result I get if I pass it "0x00EE" is:</p>
  
  <pre><code>token: 0x00EE
  error: 0
  </code></pre>
  
  <p>The problem I believe is whether I pass it something along the lines of "0x00EE" or "OxOOEE" (zero's vs capital o's). Both look identical in vi, and I am not sure if they are handled differently in this scenario. Hopefully I am just doing something really simple and stupid that I overlooked though (that's usually the case). Also, I have tried using</p>
  
  <pre><code>maskval = strtol(token, NULL, 16);
  </code></pre>
  
  <p>instead of sscanf() but I get the exact same results.</p>
  
  <p>Any ideas?</p>