Added junk found in ~harvie at harvie.cz
[mirrors/Programs.git] / c / rand.c
diff --git a/c/rand.c b/c/rand.c
new file mode 100644 (file)
index 0000000..0c06846
--- /dev/null
+++ b/c/rand.c
@@ -0,0 +1,23 @@
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+int main() {
+       int g, r, max = 10;
+       char buff[80];
+       while(1) {
+               r = rand() % max;
+               printf("hadej cislo (od 0 do"
+                       "%d):", max - 1);
+               fgets(buff, sizeof(buff)-2, stdin);
+               *strpbrk(buff, "\r\n") = '\0';
+               if (!*buff)
+                       break;
+               g = strtol(buff, NULL, 10);
+               if(r == g) puts("Bravo maestro!");
+               else printf("Loooooooozre! "
+                       "bylo to %d\n", r);
+               
+       }
+       puts("konec!");
+}
This page took 0.123481 seconds and 4 git commands to generate.