String to integer comparison in c/c++

main()
{
char str1[]=”hello”;
char str2[]=”hello”;
If(str1==str2)
printf(“Equal”);
else
printf(“unequal”);
}
Tutorial answer:
unequal
Debugging solution:
See the article(string and integer value in c/c++) you can easily understand
First str1 contain -16
Second str2 does not contain -16
So it display unequal
Whenever string come to the if condition string convert to integer.

Post a Comment

0 Comments