Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. #define strcmpi strcasecmp
  5.  
  6. int main () {
  7. int numbers[] = {5,7,2,8,4,3,1,0,6,9};
  8.  
  9. char names[10][255] = {
  10. "Emily",
  11. "Jessica",
  12. "Megan",
  13. "Chloe",
  14. "Charlotte",
  15. "Sophie",
  16. "Rebecca",
  17. "Hannah",
  18. "Ellie",
  19. "Georgia"
  20. };
  21.  
  22. int isFound = 0;
  23.  
  24. char target[255] = "Ellie";
  25.  
  26. for (int i = 0 ; i < 10 ; ++i) {
  27. if ( !strcmp(names[i], target) ) {
  28. isFound = 1;
  29. break;
  30. }
  31. }
  32.  
  33. // int target = 10;
  34.  
  35. // int length = sizeof(numbers) / 4;
  36.  
  37. // for (int i = 0 ; i < length ; ++i) {
  38. // if (target == numbers[i]) {
  39. // isFound = 1;
  40. // break;
  41. // }
  42. // }
  43.  
  44. printf("%sFOUND", isFound ? "" : "NOT ");
  45.  
  46. return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement