Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdio.h"
- #include "stdint.h"
- #include "inttypes.h"
- #include "stdio.h"
- int mystrcmp(const char *str1, const char *str2) {
- int ans = 0;
- while (*str1 != '\0' && *str2 != '\0') {
- unsigned char a = *str1;
- unsigned char b = *str2;
- if (a > b) {
- ans = 1;
- return ans;
- } else if (a < b) {
- ans = -1;
- return ans;
- }
- ++str1;
- ++str2;
- }
- if (*str1 == '\0' && *str2 != '\0') {
- ans = -1;
- } else if (*str2 == '\0' && *str1 != '\0') {
- ans = 1;
- }
- return ans;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement