Browse Source

option '-s' run srand(getpid())

tth 2 years ago
parent
commit
474814ad11
1 changed files with 7 additions and 5 deletions
  1. 7
    5
      fake-values.c

+ 7
- 5
fake-values.c View File

@@ -4,6 +4,7 @@
4 4
 
5 5
 #include  <stdio.h>
6 6
 #include  <unistd.h>
7
+#include  <stdlib.h>
7 8
 
8 9
 #include  "funcs.h"
9 10
 
@@ -15,16 +16,17 @@ int main(int argc, char *argv[])
15 16
 {
16 17
 int	opt;
17 18
 
18
-while ((opt = getopt(argc, argv, "v")) != -1) {
19
+while ((opt = getopt(argc, argv, "vs")) != -1) {
19 20
 	switch (opt) {
20
-		case 'v':	verbosity++;	break;
21
-		default:			break;
21
+		case 'v':	verbosity++;		break;
22
+		case 's':	srand(getpid());	break;
23
+		default:				break;
22 24
 		}
23 25
 	}
24 26
 
25
-if (verbosity > 1)
27
+if (verbosity > 1) {
26 28
 	fprintf(stderr, "fake values - %s %s\n", __DATE__, __TIME__);
27
-
29
+	}
28 30
 
29 31
 
30 32
 printf("%f %d\n", dtime(), random1000(0));

Loading…
Cancel
Save