Answer to Question #5907 in C++ for Kewal

Question #5907
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.

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS