An interesting problem, i just came about! I once read a question from a user. He had a WA on “THE NEXT PALINDROME” . I told him his code doesn’t output a right answer for an already palindrome string, eg:-9999. Acc to me it gave an output 9999 but it should be 10001. But he kept arguing that it always gave the correct output on his compiler. Apparently today i submitted the code in c++11 and to my shock, it did give a right answer. Its the same code. I just copied and pasted. Nothing more. Also went line by line to check if there was something I was missing. I am clueless though. Can someone tell me the reason with a proper explanation and a way to avoid it?
Problem link :- PALIN Problem - CodeChef
C++4.3.2 code link :- MQXjKN - Online C++ Compiler & Debugging Tool - Ideone.com
C++11 code link :- jxb1BS - Online C++0x Compiler & Debugging Tool - Ideone.com