Advertisement
tungint

precedent word

May 25th, 2016
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdbool.h>
  3. #include <string.h>
  4. #include <ctype.h>
  5.  
  6. bool precedence(char word1[46], char word2[46])
  7. {
  8. int i = 0;
  9. while (word1[i] != '\0')
  10. {
  11. if ((int)tolower(word1[i]) == (int)tolower(word2[i]))
  12. {
  13. i++;
  14. // if strlen of word2 shorter than word1
  15. if (word2[i] == '\0')
  16. return false;
  17. }
  18.  
  19. else if ((int)tolower(word1[i]) < (int)tolower(word2[i]))
  20. {
  21. return true;
  22. }
  23.  
  24. return false;
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement