Understanding about the string comparison

when do we have to use (strcmp) to compare the string and when can we use simple string comparison by(==)???

Hello @rastogi.g1998,

  1. When you use == operator then you can only check for equality.

  2. strcmp() provides three different types of output:
    0: A value equal to zero when both strings are found to be identical. That is, That is, All of the characters in both strings are same.
    <0: A value less than zero is returned when the first not matching character in leftStr have lesser ASCII value than the corresponding character in rightStr.
    >0: A value greater than zero is returned when the first not matching character in leftStr have the greater ASCII value than the corresponding character in rightStr or we can also say.

So, their application depends upon your requirement.

Hope, this would help.
Give a like, if you are satisfied.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.