Write a function that takes two char arguments and returns 0 if both the arguments are equal. The function returns -1 if the first argument is smaller than the second and 1 if the second argument is smaller than the first.
1
Expert's answer
2012-01-06T10:30:23-0500
int comparison(char a[], char b[]){ return -strcmp(a,b); }
A zero value indicates that both strings are equal. A value 1 indicates if the first character that does not match has a greater value in a than in b, and a value less than zero indicates the opposite.
Comments
Leave a comment