aboutsummaryrefslogtreecommitdiffstats
path: root/src/string/strfry.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2015-09-01 21:07:54 +0200
committerMattias Andrée <maandree@operamail.com>2015-09-01 21:07:54 +0200
commitac044784a6ce64ff15610d4b70750065a7f01b80 (patch)
tree8ac8629c0089099f21be9107a5d3779963d33ca0 /src/string/strfry.c
parentadd memfrob (diff)
downloadslibc-ac044784a6ce64ff15610d4b70750065a7f01b80.tar.gz
slibc-ac044784a6ce64ff15610d4b70750065a7f01b80.tar.bz2
slibc-ac044784a6ce64ff15610d4b70750065a7f01b80.tar.xz
start on makefile and fixing warnings and errors
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r--src/string/strfry.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/string/strfry.c b/src/string/strfry.c
index f020202..cf8d643 100644
--- a/src/string/strfry.c
+++ b/src/string/strfry.c
@@ -34,13 +34,16 @@
char* strfry(char* anagram)
{
size_t i, j;
+ int r;
char t;
if (anagram == NULL)
return NULL;
for (i = strlen(anagram); --i;)
{
- j = (int)((double)rand() / (RAND_MAX + 1));
+ r = rand();
+ j = (int)((double)r / (RAND_MAX + 1));
t = anagram[i], anagram[i] = anagram[j], anagram[j] = t;
}
+ return anagram;
}