wrong answer on c++ 4.3.2, but works on c++ 11

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

2 Likes

Make the two arrays global in c++ 4.3.2 .Maybe c++ 4.3.2 can’t handle this much stack memory usage…not sure though.

code courtesy :- hellboy054 :stuck_out_tongue:

1 Like

Nope! Dint work still! Something else you can figure out?

what case is it failing now?

It fails always on c++ 4.3.2. But it never does on c++11. Same cases as before.

when i put the two 10^6 sized char arrays outside of main, it worked for me