HabKaffee

Untitled

Apr 9th, 2021 (edited)
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.61 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <limits.h>
  4. #include <time.h>
  5. #include <stdbool.h>
  6. #include <string.h>
  7. int main() {
  8.     srand(time(NULL));
  9.     char str[256] = {0};
  10.     puts("If you want to have a random number in [1,100] write /roll\nIf you want to exit write exit");
  11.     while (true) {
  12.         gets(str);
  13.         if (!(strcmp(str, "/roll"))) {
  14.             printf("%i\n", (rand()%100) + 1);
  15.         } else if (!(strcmp(str, "exit"))) {
  16.             puts("Have a nice day");
  17.             break;
  18.         } else {
  19.             puts("Wrong command, try again");
  20.         }
  21.     }
  22.  
  23.     return 0;
  24. }
Add Comment
Please, Sign In to add comment