Advertisement
Guest User

Untitled

a guest
Apr 27th, 2015
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. //
  2. // main.c
  3. // Adam
  4. //
  5. // Created by Shahin on 2015-03-09.
  6. // Copyright (c) 2015 98% Chimp. All rights reserved.
  7. //
  8.  
  9. #include <stdio.h>
  10. #include <stdbool.h>
  11. #include <ctype.h>
  12. #include <string.h>
  13.  
  14. int main(int argc, const char * argv[]) {
  15. // insert code here...
  16. bool isDone = false;
  17.  
  18. while (isDone == false) {
  19. printf("Please type in your question for Adam (type exit to discontinue): ");
  20.  
  21. char input[]="";
  22. rewind(stdin);
  23. scanf("%[^\n]", input);
  24. long length = strlen(input);
  25. long len = length - 1;
  26. char *s1 = &input[len];
  27. char *s2 = "?";
  28. char *exit = "exit";
  29. bool uppercase = true;
  30.  
  31. if (strcmp(input, exit) == 0) {
  32. isDone = true;
  33. printf("Yo yo!\n");
  34. }
  35. else if (length > 0) {
  36.  
  37. for (int i = 0; i < length; i++) {
  38. if (!((input[i] >= 65 && input[i] <= 90) || input[i] == 32)) {
  39. uppercase = false;
  40. break;
  41. }
  42. }
  43.  
  44. if (uppercase) {
  45. printf("Woah, chill out!\n");
  46. }
  47.  
  48. else if (strcmp(s1, s2) == 0) {
  49. printf("Sure!\n");
  50. }
  51. else {
  52. printf("Whatever!\n");
  53. }
  54. }
  55. else {
  56. printf("Fine. Be that way!\n");
  57. }
  58. }
  59. return 0;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement