This program should tell me are two string equal or less.. But ain't working..
Code:cmp(char *p1, char *p2){ int i = 0, cont = 1; while( *p1 != '\0' && *p2 != '\0' && cont != 0 ){ if ( *( p1 + i) == *( p2 + i ) ) i++; else cont = 0; } if ( *p1 == '\0' || *p2 == '\0' ) cont = 0; printf("%d",cont); return cont; } #include <stdio.h> int main() { char s1[20], s2[20], *p1, *p2; printf("Input String "); gets(s1); p1 = &s1; printf("Input second String "); gets(s2); p2 = &s2; return cmp(p1,p2); }