but it's working on the length of the strings not checking the chars itself!
Logic needs to be applied here.
Process of elimination.
How would I check for same string between two strings?
first I'd check to be sure they are the same length before going further.
if length equals same then check to be sure words match else it is not going to be the same then return results reflecting what you have found.
you could use strlen to take care of the first part, then loop through your strings comparing them letter for letter to be sure they match, if no match, well you should know the rest.
NetBSD strcmp source code
Code:
int
strcmp(const char *s1, const char *s2)
{
_DIAGASSERT(s1 != NULL);
_DIAGASSERT(s2 != NULL);
while (*s1 == *s2++)
if (*s1++ == 0)
return (0);
return (*(const unsigned char *)s1 - *(const unsigned char *)--s2);
}