Advertisement
dtung

bot.c

Apr 5th, 2020
370
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.84 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <conio.h>
  5.  
  6. char *ques[] = {"Hi\n", "How are you?\n", "What is your name?\n", "What is the capital of Bangladesh?\n"};
  7. char *ans[] = {"Hello!", "I am fine", "It's sss and you?", "The capital of Bangladesh is Dhaka"};
  8.  
  9. char human_talks[150];
  10. char cont;
  11.  
  12. int main()
  13. {
  14.     int n = sizeof(ques)/sizeof(char *);
  15.     printf("size %d\n", n);
  16.     do
  17.     {
  18.  
  19.         printf("Ask : ");
  20.         // scanf("%[^\n]", &human_talks);
  21.         fgets(human_talks, 150, stdin);
  22.         int i = 0;
  23.         for (i = 0; i < 4; i++)
  24.         {
  25.  
  26.             if (strcmp(ques[i], human_talks) == 0)
  27.             {
  28.                 printf("Ans : %s\n", ans[i]);
  29.                 break;
  30.             }
  31.         }
  32.         cont = getch();
  33.     } while (cont == 'y');
  34.     // getch();
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement