You are not logged in. Please login at to post your questions!


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 :- C++4.3.2 code link :- C++11 code link :-

asked 14 Oct '14, 02:16

pranjalranjan's gravatar image

accept rate: 20%

edited 14 Oct '14, 02:17


code courtesy :- hellboy054 :p

(14 Oct '14, 02:20) pranjalranjan4★

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.


answered 14 Oct '14, 02:55

fauzdar65's gravatar image

accept rate: 21%

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

(14 Oct '14, 02:56) pranjalranjan4★

what case is it failing now?

(14 Oct '14, 03:02) fauzdar652★

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

(14 Oct '14, 03:02) pranjalranjan4★

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

(14 Oct '14, 03:04) fauzdar652★
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:


question asked: 14 Oct '14, 02:16

question was seen: 631 times

last updated: 14 Oct '14, 03:04