summaryrefslogtreecommitdiffstats
path: root/lib/randstring.c
diff options
context:
space:
mode:
authorAnton L. Šijanec <sijanecantonluka@gmail.com>2020-05-16 19:35:55 +0200
committerAnton L. Šijanec <sijanecantonluka@gmail.com>2020-05-16 19:35:55 +0200
commit587f44fd93a0024500418ce25bf01d0f177644f4 (patch)
tree13a981e5bc369cca8cc99ad9547d54b4c76673f5 /lib/randstring.c
parentfix to allow nested commands (diff)
downloadbverbose-587f44fd93a0024500418ce25bf01d0f177644f4.tar
bverbose-587f44fd93a0024500418ce25bf01d0f177644f4.tar.gz
bverbose-587f44fd93a0024500418ce25bf01d0f177644f4.tar.bz2
bverbose-587f44fd93a0024500418ce25bf01d0f177644f4.tar.lz
bverbose-587f44fd93a0024500418ce25bf01d0f177644f4.tar.xz
bverbose-587f44fd93a0024500418ce25bf01d0f177644f4.tar.zst
bverbose-587f44fd93a0024500418ce25bf01d0f177644f4.zip
Diffstat (limited to 'lib/randstring.c')
-rw-r--r--lib/randstring.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/randstring.c b/lib/randstring.c
index 2eeed8f..dd5ca8f 100644
--- a/lib/randstring.c
+++ b/lib/randstring.c
@@ -1,12 +1,13 @@
#pragma once
+#include <time.h>
char *randstring(size_t length) {
static char charset[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
char *randomString = NULL;
-
+ time_t t;
if (length) {
randomString = malloc(sizeof(char) * (length +1));
-
+ srand((unsigned) time(&t));
if (randomString) {
for (int n = 0;n < length;n++) {
int key = rand() % (int)(sizeof(charset) -1);