The_Law

Untitled

Sep 24th, 2018
395
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.52 KB | None | 0 0
  1. #include <ctype.h>
  2.  
  3. int
  4. mystrspccmp(const char *str1, const char *str2)
  5. {
  6.     while (*str1 || *str2) {
  7.         while (isspace(*str1)) {
  8.             ++str1;
  9.         }
  10.         while (isspace(*str2)) {
  11.             ++str2;
  12.         }
  13.         if (*str1 == *str2) {
  14.             ++str1;
  15.             ++str2;
  16.         } else if(*str1 != *str2) {
  17.             break;
  18.         }
  19.     }
  20.  
  21.     return (unsigned char) *str1 - (unsigned char) *str2;
  22. }
  23.  
  24. int
  25. main(void)
  26. {
  27.     printf("%d", mystrspccmp("aaaa  ", "aaaa"));
  28. }
Advertisement
Add Comment
Please, Sign In to add comment