0
Why I'm getting different output in different compilers?
See c style strings comparison... Input *Saurabh Kumar* In a compiler i got -1, 83 In another i got -115, 115 Why and how??? See and please tell me... https://code.sololearn.com/cMuAdE5Kr2a7/?ref=app
4 Respostas
+ 3
This is because of how strcmp() is implemented by your compiler implementation.
Standards only specify that this function should either return a 0 ( for equality ), negative number (when the first character that does not match has a lower value in ptr1 than ptr2) or a positive number otherwise.
+ 3
This way I constantly get (-32) and (32) from `strcmp`.
`strcmp` returns non zero here because <temp> contains the same letters to those in <full_name>, but in different case (<temp> has uppercase version).
The result (32) and (-32) resulted from the distance between the first `char` found to be different (at same index) in both C-string.
(Edited)
+ 1
$|<|>_α&
You haven't stored anything into <temp> and yet you are comparing <temp> and <full_name>.
Check what you got in <temp> and ask yourself whether that comparison was in order.
+ 1
Ipang ohh sorry!!!
ok ,,, Modified now......
Now look in to that and consider my problem