Your central comparison is flawed:
if (str[i] != str[i+halflen])
This isn't comparing the two characters you think it is.
Try entering "HelloHello" into your program, it will say it is a palindrome!
You need to compare these two:
if (str[i] != str[len-i-1])
(and fix the braces, as suggested in the other answer)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…