#include <stdio.h>
int strrcmp(char *str, char *sub){
while(*str!='\0'){
if(*str==*sub){
*str++;
*sub++;
}
else{
return 1;
}
}
return 0;
}
int main() {
char str[10] = "adarsh";
char sub[10] = "adarsh";
int res = strrcmp(str,sub);
if(res==0){
printf("strings are equal");
}
else{
printf("strings are diff");
}
}
#if 0
int strcmp(const char *s1, const char *s2) {
while (*s1 == *s2) {
if (*s1 == '\0')
return 0;
s1++;
s2++;
}
return (*s1 > *s2) ? 1 : -1;
}
int main() {
char a[10]="adarsh";
char b[10]="adarsh";
strcmp(b,a);
printf("%d",strcmp(b,a));
}
#endif
To embed this program on your website, copy the following code and paste it into your website's HTML: