From 587f44fd93a0024500418ce25bf01d0f177644f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20L=2E=20=C5=A0ijanec?= Date: Sat, 16 May 2020 19:35:55 +0200 Subject: easier to add commands, accept values, added substirng --- lib/randstring.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/randstring.c') 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 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); -- cgit v1.2.3