int main(void) {
char s[] = "ab";
char *s1 = "ab";
if(strcmp(s, s1))
printf("%d", 24);
else
printf("%d", 23);
return EXIT_SUCCESS;
}
Why it is giving 23 answer?
This is because strcmp returns 0 if strings are equal. 0 is treated as false in C.
strcmp(string1, string2)
if Return value < 0 then it indicates string1 is less than string2
if Return value > 0 then it indicates string2 is less than string1
if Return value = 0 then it indicates string1 is equal to string2
strcmpdoes.