I was just trying to execute this program in code blocks and i got an output of 0,1,-1 , in some other compiler i got result 0,4,-1 but according to the working of strcmp() , i should get 0,4,-32 , i am not able to understand why i am getting diferent outputs on different compilers.
#include<stdio.h>
#include<string.h>
int main()
{
char string1[]="Jerry";
char string2[]="Ferry";
int i,j,k;
i=strcmp(string1,"Jerry");
j=strcmp(string1,string2);
k=strcmp(string1,"Jerry boy");
printf("%d %d %d \n",i,j,k);
return 0;
}
strcmp()
returns value greater than or less than or equal to 0
. That means it will return 0
for sure if two strings are equal otherwise it can return any integer value greater or less than 0
.