Skip to content

Instantly share code, notes, and snippets.

@bytorbrynden
Created February 16, 2016 21:03
Show Gist options
  • Save bytorbrynden/60b47e1f4129a396973e to your computer and use it in GitHub Desktop.
Save bytorbrynden/60b47e1f4129a396973e to your computer and use it in GitHub Desktop.
// 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