Discussion :: Library Functions - True / False Questions (Q.No.5)
|Kumar said: (Jan 2, 2012)|
|Can you explain the last statement?|
|Sin said: (Dec 13, 2012)|
|This is the compiler implementation of strcmp function.
for loop checks first two characters in string if equal continues to next characters and checks if null if null prints 0 else skips the for lop then decides which character is greater neglect this in the last line. Its just type of pointer (unsigned char *)
if first char lesser then -1 else 1. If condition true then 1 else 2 ((condition?1:2)).
|Vishal said: (Nov 24, 2014)|
|How and When will it return values other than 0, -1 or 1?|
|Christobal said: (Mar 14, 2016)|
|The code example shown won't return values other than 0, 1 and -1. This is not a complete solution if the function is supposed to return the difference between the first non-matching characters.|
Post your comments here:
Email : (optional)
» Your comments will be displayed only after manual approval.