crsandu

Untitled

Mar 19th, 2018
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.41 KB | None | 0 0
  1. static char string_compare(const char *string_1, const char *string_2) // compare 2 strings case insensitive
  2. {
  3.     int val;
  4.     for (;; string_1++, string_2++)
  5.     {
  6.         val = tolower(*string_1) - tolower(*string_2); // check which character is bigger
  7.         if (val != 0 || (*string_1 == '\0')) // stop when value is !0 or when string_1 is finished
  8.         {
  9.             return val;
  10.         }
  11.     }
  12. }
Advertisement
Add Comment
Please, Sign In to add comment