public inbox for linux-man@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Add example to rand.3
@ 2022-12-26 21:50 Jonny Grant
  2022-12-26 22:29 ` Alejandro Colomar
  0 siblings, 1 reply; 27+ messages in thread
From: Jonny Grant @ 2022-12-26 21:50 UTC (permalink / raw)
  To: linux-man; +Cc: Michael Kerrisk

Hi Alejandro
Please find below a patch.

2022-12-26  Jonathan Grant <jg@jguk.org>
	* man3/rand.3: Add example to rand.3 seed with time(NULL)


From 2d4501354ea6c465173fe6c089dfbcc80393a644 Mon Sep 17 00:00:00 2001
From: Jonathan Grant <jg@jguk.org>
Date: Mon, 26 Dec 2022 21:48:17 +0000
Subject: [PATCH] add rand.3 example

Signed-off-by: Jonathan Grant <jg@jguk.org>
---
 man3/rand.3 | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/man3/rand.3 b/man3/rand.3
index 572471749..c1542fb56 100644
--- a/man3/rand.3
+++ b/man3/rand.3
@@ -164,6 +164,20 @@ when good randomness is needed.
 .BR random (3)
 instead.)
 .SH EXAMPLES
+
+A possibly useful seed value would be by calling
+.BR rand ()
+with the result of
+
+.BR time ()
+as that varies with every call
+
+.EX
+srand((unsigned int)time(NULL));
+.EE
+.in
+.PP
+
 POSIX.1-2001 gives the following example of an implementation of
 .BR rand ()
 and
-- 
2.37.2

^ permalink raw reply related	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2022-12-30 21:50 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-26 21:50 [PATCH] Add example to rand.3 Jonny Grant
2022-12-26 22:29 ` Alejandro Colomar
2022-12-27 13:07   ` Cristian Rodríguez
2022-12-27 23:33     ` Alejandro Colomar
2022-12-28  0:00       ` G. Branden Robinson
2022-12-28  0:41         ` Alejandro Colomar
2022-12-28 12:21           ` Cristian Rodríguez
2022-12-30 18:15             ` Joseph Myers
2022-12-30 18:20               ` Alejandro Colomar
2022-12-30 18:50                 ` Joseph Myers
2022-12-30 18:58                   ` Alejandro Colomar
2022-12-30 19:11               ` Cristian Rodríguez
2022-12-30 21:08                 ` Joseph Myers
2022-12-30 21:15                   ` Internal organization of "the implementation" (was: [PATCH] Add example to rand.3) Alejandro Colomar
2022-12-30 21:50                     ` Joseph Myers
2022-12-27 21:37   ` [PATCH] Add example to rand.3 Jonny Grant
2022-12-27 23:11     ` Alejandro Colomar
2022-12-28 20:51       ` Jonny Grant
2022-12-28 20:56         ` Alejandro Colomar
2022-12-28 21:03           ` Alejandro Colomar
2022-12-28 21:04             ` Alejandro Colomar
2022-12-28 21:25               ` Jonny Grant
2022-12-28 21:32                 ` Alejandro Colomar
2022-12-28 21:04           ` Cristian Rodríguez
2022-12-28 21:11             ` Alejandro Colomar
2022-12-28 21:19               ` Jonny Grant
2022-12-28 21:18             ` Alejandro Colomar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox