diff options
author | Aaron Ball <nullspoon@oper.io> | 2019-08-30 20:32:02 -0600 |
---|---|---|
committer | Aaron Ball <nullspoon@oper.io> | 2019-08-30 20:34:13 -0600 |
commit | 861070c2fd4fccfae91c758e110d061e4bb57bf2 (patch) | |
tree | 537e542a499047084a5775d7c13defff861a7f44 /src | |
parent | 1dd4ef2a85c17fa59243a16f5b4680b6f00b8644 (diff) | |
download | upwgen-861070c2fd4fccfae91c758e110d061e4bb57bf2.tar.gz upwgen-861070c2fd4fccfae91c758e110d061e4bb57bf2.tar.xz |
Streamline random selection code in main
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 13 |
1 files changed, 5 insertions, 8 deletions
@@ -156,23 +156,20 @@ int main(int argc, char* argv[]) { srand((unsigned)seed); cursor = set; - while(len > 0) { - // Randomly select the number of character sets to advance through (max 10) + while((len--) > 0) { + // Randomly select the number of character sets to advance through int i = rand() % 10; - while(i > 0) { + while((i--) > 0) { // Loop - if(!cursor->next) { + if(!cursor->next) cursor = set; - } else { + else cursor = cursor->next; - } - i--; } // Randomly select an integer within the set size int rc = rand() % cursor->count; // Random char within set printf("%lc", cursor->chars[rc]); - len--; } printf("\n"); |