Answer by Deduplicator for String comparison using pointers
There's another huge bug in your code which stems from a quirk of C (and C++):Plain char can be either signed or unsigned.Next, do you really want to normalize the return-values to one of -1, 0 and 1,...
View ArticleAnswer by fer-rum for String comparison using pointers
Remember when you learned that arrays are nothing but the pointer to the first element of the same array? You can do this the other way around too: *(s1 + 1) is equivalent to s1[1].In the second...
View ArticleAnswer by coderodde for String comparison using pointers
You don't need pointers to character pointers at all:int str_cmp(const char* s1, const char* s2){ while (*s1 != '\0'&& *s1 == *s2) {++s1;++s2; } if (*s1 == *s2) { return 0; } return *s1 <...
View ArticleString comparison using pointers
This piece of code works fine. But I'm wondering if it can be done in a more efficient way. More specifically, this part (*(s1 + i)) if it possible to force it to sequence through entire array...
View Article
More Pages to Explore .....