Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. // an old joke which happens that a machine is better at telling it. Happy Eid.
  2.  
  3. #include <stdio.h>
  4. #include <string.h>
  5. #include <ctype.h>
  6.  
  7. int strcmp_casei(char const *a, char const *b);
  8.  
  9. int main()
  10. {
  11. char *left = NULL;
  12. size_t n;
  13.  
  14. do {
  15. printf("Eid and Saeed went up the mountain."
  16. "Saeed went down, who is left?\n");
  17. getline(&left, &n, stdin);
  18. } while (strcmp_casei(left, "Eid\n") == 0);
  19.  
  20. return 0;
  21. }
  22.  
  23. int strcmp_casei(char const *a, char const *b)
  24. {
  25. for (;; a++, b++) {
  26. int d = tolower(*a) - tolower(*b);
  27. if (d != 0 || !*a)
  28. return d;
  29. }
  30.  
  31. return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement