In the example provided here, the strings are of different. I just wanted to ask what happens when at some index the array elements differ as in
char * str1 = "Hello";
char * str2 = "Helio";
j = strcmp(str1, str2);
"Less in length? Less in what?" Less lexicographically. Here's the source from a well known C library implementation:
int strcmp(char * src, char * dest) { int ret = 0 ; while(!(ret=*(unsigned char *)src- *(unsigned char *)dest) && *dest) { ++src; ++dest; } if(ret<0) ret = -1 ; else if(ret>0) ret=1; return(ret); }
Thanks, That was exactly what I was asking. I wanted to use the return values of strcmp for sorting strings.