I have this code:


Note:
boom.ok[1][0] has the character "a" while boom.ok[[tempr[0]][0] contains the string "ay".

if ( strcmp(&boom.ok[1][0],&boom.ok[[tempr[0]][0]) == 1)
printf("Hello");

if ( strcmp(&boom.ok[1][0],&boom.ok[[tempr[0]][0]) == 0)
printf("Hello");

None of these statement prints hello. Why?

Edited 4 Years Ago by jodzjcm: grammar

What if the return value from strcmp is -1?

Is that possible? Am I right? The only return value of strcmp function is only 0 and 1 when the string or variable compared is not equal and equal?

Yes, it's possible.
The possible values are -1, 0, 1.
...but are actually described (in the documentation) as
Less than zero
Equal to zero
Greater than zero
...and serve specific purposes.

Edited 4 Years Ago by thines01: n/a

I think it return 0 if they are equal,
however,
return either a positive or negative value of the difference, can be -2 or 4 5 anything.

This question has already been answered. Start a new discussion instead.