title: uint64_t string conversion and extraction of first 4 characters
body: <p>I've been handed this function that checks if a given 4 digit PIN number is correct. This PIN is a string of length 5 (e.g. &quot;1234\0&quot;). The real PIN is obtained after some calculations, by converting a uint64_t to string and extracting the first 4 characters:</p>
  <pre><code>uint8_t pin_verification(uint64_t number, uint8_t *pin)
  {
    uint8_t string[14];
  
    // ASCII string conversion
    sprintf((char *)(string), &quot;%llu&quot;, number);
  
    // Pin verification
    if (memcmp(pin, string, 4))
    {
      return 0;
    }
    else
    {
      return 1;
    }
  }
  </code></pre>
  <p>I've been told that it works, but I'm trying to run this on a STM32 chip and the <code>sprintf</code> function doesn't work properly. I've tried solutions like using the <code>PRIu64</code> modifier from the <code>inttypes.h</code> library, but it still doesn't work.</p>
  <p>I don't mind to change this function if there is a way to avoid the use of <code>sprintf</code>.</p>
  <p>Thanks!</p>