Simple random string generator in C
You are effectively picking your first hex digit from "123456789ABCDEF" (no zero) and the subsequent digits from "0123456789ABCDEF".  Hence it might be better to adjust the first random pick:

// This assumes that str_len is at least 1.
*str = *(digits + (1 + rand() % 15));  // Pick first char in range 1..15
str++;

// For loop starts at 1 as str[0] already picked.
for (int i = 1; i &lt; str_len; i++) {
    *str = *(digits + (rand() % 16));  // Following chars in range 0..15
    str++;
}


That eliminates the tmp_char variable and the while loop, which makes the code a lot cleaner, to my eye anyway.