http://ideone.com/6rh6rI
Let’s assume you want to solve the PALIN problem (which you should note in your post). Then you should read this thread as your code has got the exactly same problem.