`
random()` has a flat probability distribution, and containers cannot have more than 2^32 elements. so `
char_array[random(#char_array)]` is perfect for generating a random character. If you need to generate a password, use `
/dev/urandom` file (/dev/random can get "empty" so it's not reliable) because "urandom" has cryptographically secure randomness quality. The number of digits is the
decimal logarithm of a number, it's NOT the same as the
numerical value. The average output of random is always equal to half its input (normalized/flat distribution), that's why the number of digits is almost the same as the digits in the input. If you want higher probability for lower numbers, then you're looking for a
inverse logarithmic distribution, which looks like a
curve when plotted graphically. A password gen. with "InvLog. dist.", would return text like "aabcbaaaabacbabaabcb" instead of "enchuwbrguydiuqpakxnznbyr"