Created
February 16, 2016 21:03
-
-
Save bytorbrynden/60b47e1f4129a396973e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is supposed to be an implementation of C's "strcmp" function, | |
// but it looks like something is missing... | |
int strcmp(c_string s1, c_string s2) | |
{ | |
const size_t str1_len = strlen(s1); | |
const size_t str2_len = strlen(s2); | |
if (str1_len < str2_len) | |
{ | |
return -1; | |
} | |
else if (str1_len > str2_len) | |
{ | |
return 1; | |
} | |
else | |
{ | |
return 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment