HabKaffee

Untitled

Apr 9th, 2021 (edited)
183
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data Copied